Use GTS output for docker metadata #98
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: Test and Build | |
| on: | |
| push: | |
| branches: ["main"] | |
| # Publish semver tags as releases. | |
| tags: ["v*.*.*"] | |
| pull_request: | |
| branches: ["main"] | |
| env: | |
| # Use docker.io for Docker Hub if empty | |
| REGISTRY: ghcr.io | |
| # github.repository as <account>/<repo> | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| git-that-semver: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| outputs: | |
| GTS_DOCKER_VERSION: ${{ steps.git-that-semver.outputs.GTS_DOCKER_VERSION }} | |
| GTS_DOCKER_TAGS: ${{ steps.git-that-semver.outputs.GTS_DOCKER_TAGS }} | |
| GTS_JSON: ${{ steps.git-that-semver.outputs.GTS_JSON }} | |
| GTS_YAML: ${{ steps.git-that-semver.outputs.GTS_YAML }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - id: git-that-semver | |
| name: git-that-semver | |
| uses: ./.github/actions/git-that-semver | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: git-that-semver | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Lint | |
| run: bun lint | |
| - name: Test | |
| run: bun test | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| needs: [test, git-that-semver] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Debug GTS outputs | |
| run: | | |
| echo "GTS_DOCKER_VERSION: ${{ needs.git-that-semver.outputs.GTS_DOCKER_VERSION }}" | |
| echo "GTS_DOCKER_TAGS: ${{ needs.git-that-semver.outputs.GTS_DOCKER_TAGS }}" | |
| echo "GTS_JSON: ${{ needs.git-that-semver.outputs.GTS_JSON }}" | |
| echo "GTS_YAML: ${{ needs.git-that-semver.outputs.GTS_YAML }}" | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: |- | |
| ${{ join(fromJson(needs.git-that-semver.outputs.GTS_JSON).strategies.docker.tags, ' | |
| ') }} | |
| labels: | | |
| org.opencontainers.image.version=${{ fromJson(needs.git-that-semver.outputs.GTS_JSON).strategies.docker.version }} | |
| - name: Debug metadata-action outputs | |
| run: | | |
| echo "${{ toJson(steps.meta.outputs) }}" | |
| - name: Build and push Docker image | |
| id: build-and-push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| platforms: linux/amd64,linux/arm64 | |
| context: . | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |