CI: add GHCR_URL env var #633
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | ||
| name: meta | ||
| env: | ||
| GHCR_URL: "ghcr.io/${{ github.repository }}" | ||
| GH_TOKEN: ${{ github.token }} | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - 'main' | ||
| - 'release/**' | ||
| tags: | ||
| - '*' | ||
| jobs: | ||
| trigger_workflow: | ||
| name: trigger workflow based on changed files | ||
| runs-on: ubuntu-22.04 | ||
| outputs: | ||
| check_container_image: ${{ steps.check_container_image.outputs.result }} | ||
| container_any_changed: ${{ steps.changed_files_yaml.outputs.container_any_changed }} | ||
| image_any_changed: ${{ steps.changed_files_yaml.outputs.image_any_changed }} | ||
| metadata_json: ${{ steps.metadata.outputs.json }} | ||
| metadata_labels: ${{ steps.metadata.outputs.labels }} | ||
| metadata_tags: ${{ steps.metadata.outputs.tags }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| # fetch full history to be able to gather changed files in all new commits | ||
| fetch-depth: 0 | ||
| - uses: tj-actions/changed-files@v45 | ||
| if: ${{ github.ref_type != 'tag' }} | ||
| id: changed_files_yaml | ||
| with: | ||
| files_yaml: | | ||
| container: | ||
| - '.github/workflows/build-container.yml' | ||
| - 'Dockerfile' | ||
| - 'container.gitconfig' | ||
| - 'utils.sh' | ||
| image: | ||
| - 'CMakeLists.txt' | ||
| - 'main/**' | ||
| - 'partitions_willow.csv' | ||
| - 'sdkconfig.defaults' | ||
| - 'spiffs/**' | ||
| since_last_remote_commit: true | ||
| - name: extract metadata | ||
| id: metadata | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: $GHCR_URL | ||
| tags: | | ||
| type=ref,event=tag | ||
| type=ref,event=pr | ||
| type=ref,event=branch | ||
| - name: extract tag name | ||
| id: tag | ||
| run: | | ||
| tag=${{ fromJSON(steps.metadata.outputs.json).tags[0] }} | ||
| echo "tag=${tag##*:}" >> $GITHUB_OUTPUT | ||
| - name: debug | ||
| run: | | ||
| echo "${{ steps.metadata.outputs.json }}" | ||
| echo "${{ steps.tag.outputs.tag }}" | ||
| - uses: cloudposse/github-action-docker-image-exists@0.2.0 | ||
| continue-on-error: true | ||
| id: check_container_image | ||
| if: ${{ steps.changed_files_yaml.outputs.container_any_changed == 'false' && steps.changed_files_yaml.outputs.image_any_changed == 'true' }} | ||
| with: | ||
| image_name: "${{ github.repository }}" | ||
| registry: ghcr.io | ||
| tag: "${{ steps.tag.outputs.tag }}" | ||
| - name: debug | ||
| run: | | ||
| echo "${{ steps.check_container_image.outputs.result }}" | ||
| build_container: | ||
| if: ${{ needs.trigger_workflow.outputs.container_any_changed == 'true' || github.ref_type == 'tag' }} | ||
| uses: ./.github/workflows/build-container.yml | ||
| needs: trigger_workflow | ||
| with: | ||
| container-image: ${{ fromJSON(needs.trigger_workflow.outputs.metadata_json).tags[0] }} | ||
| labels: ${{ needs.trigger_workflow.outputs.metadata_labels }} | ||
| tags: ${{ needs.trigger_workflow.outputs.metadata_tags }} | ||
| build_willow: | ||
| if: ${{ needs.trigger_workflow.outputs.container_any_changed == 'false' && needs.trigger_workflow.outputs.image_any_changed == 'true' }} | ||
| uses: ./.github/workflows/build-willow.yml | ||
| needs: trigger_workflow | ||
| with: | ||
| container-image: ${{ needs.trigger_workflow.outputs.check_container_image && fromJSON(needs.trigger_workflow.outputs.metadata_json).tags[0] || "${{ env.GHCR_URL }}:main" }} | ||
|
Check failure on line 100 in .github/workflows/meta.yml
|
||