Skip to content

Commit

Permalink
ci: combine publish and docker build into one workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bambanah committed Aug 23, 2024
1 parent bf50fdf commit cc27d04
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 55 deletions.
51 changes: 0 additions & 51 deletions .github/workflows/build-publish-docker.yml

This file was deleted.

55 changes: 51 additions & 4 deletions .github/workflows/create-release-or-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ on:

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: write
pull-requests: write

jobs:
create-release-or-publish:
runs-on: ubuntu-latest

outputs:
published: ${{ steps.changesets.outputs.published }}

permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
Expand All @@ -32,3 +36,46 @@ jobs:
publish: pnpm changeset tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-publish-docker:
runs-on: ubuntu-latest

needs: create-release-or-publish
if: needs.release.outputs.published == 'true'

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit cc27d04

Please sign in to comment.