Rename GitVersion.yml to .yaml #12
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: Build devcontainers | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - '*' | |
| tags-ignore: | |
| - '*' | |
| jobs: | |
| prepare-tags: | |
| name: Prepare tags | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| tags: ${{ steps.extract-tag-parts.outputs.tags }} | |
| base-image-tag: ${{ steps.set-base-image-tag.outputs.base-image-tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up GitVersion | |
| uses: gittools/actions/gitversion/setup@bc6623af8fc07d5a8903052dd46da33403eec8e8 | |
| with: | |
| versionSpec: 6.7.0 | |
| - name: Determine version | |
| id: gitversion | |
| uses: gittools/actions/gitversion/execute@bc6623af8fc07d5a8903052dd46da33403eec8e8 | |
| - name: Generate image tags | |
| id: metadata | |
| uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=raw,value=${{ steps.gitversion.outputs.semVer }},enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| type=raw,value=${{ steps.gitversion.outputs.major }}.${{ steps.gitversion.outputs.minor }},enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| type=raw,value=${{ steps.gitversion.outputs.major }},enable=${{ steps.gitversion.outputs.major != '0' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| type=raw,value=${{ steps.gitversion.outputs.semVer }}-${{ steps.gitversion.outputs.branchName }}-${{ steps.gitversion.outputs.commitsSinceVersionSource }}-{{sha}} | |
| type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| - name: Strip image name from tags | |
| id: extract-tag-parts | |
| env: | |
| METADATA_JSON: ${{ steps.metadata.outputs.json }} | |
| run: | | |
| TAGS=$(echo "$METADATA_JSON" | jq -r '[.tags[] | split(":") | last] | join(",")') | |
| echo "$TAGS" | |
| echo "tags=$TAGS" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Determine base image tag | |
| id: set-base-image-tag | |
| run: | | |
| FIRST_TAG=$(echo "${{ steps.extract-tag-parts.outputs.tags }}" | cut -d',' -f1) | |
| echo "base-image-tag=$FIRST_TAG" >> $GITHUB_OUTPUT | |
| shell: bash | |
| build-base: | |
| name: Build base | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - prepare-tags | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Build base devcontainer | |
| uses: ./.github/actions/build-devcontainer | |
| with: | |
| image: base | |
| resolved-tags: ${{ needs.prepare-tags.outputs.tags }} | |
| push-image: ${{ github.event_name != 'pull_request' }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Export base image for dependent jobs | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| IMAGE="ghcr.io/${{ github.repository }}/base:${{ needs.prepare-tags.outputs.base-image-tag }}" | |
| docker image inspect "$IMAGE" >/dev/null 2>&1 | |
| docker save "$IMAGE" | gzip > base.tar.gz | |
| shell: bash | |
| - name: Upload base image as artifact | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: base | |
| path: base.tar.gz | |
| if-no-files-found: error | |
| retention-days: 1 | |
| build-child-images: | |
| name: Build ${{ matrix.image }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| needs: | |
| - prepare-tags | |
| - build-base | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: [dotnet, go, hugo, javascript, python] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - name: Build ${{ matrix.image }} devcontainer | |
| uses: ./.github/actions/build-child-devcontainer | |
| with: | |
| image: ${{ matrix.image }} | |
| image-tags: ${{ needs.prepare-tags.outputs.tags }} | |
| base-image-tag: ${{ needs.prepare-tags.outputs.base-image-tag }} | |
| push-image: ${{ github.event_name != 'pull_request' }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| cleanup-workflows: | |
| name: Cleanup workflows | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: write | |
| contents: read | |
| steps: | |
| - name: Delete old workflow runs | |
| uses: Mattraks/delete-workflow-runs@b3018382ca039b53d238908238bd35d1fb14f8ee | |
| with: | |
| token: ${{ github.token }} | |
| repository: ${{ github.repository }} | |
| retain_days: 30 | |
| keep_minimum_runs: 5 |