Skip to content

Commit

Permalink
ci: overhaul release and publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bambanah committed Aug 23, 2024
1 parent 902419c commit 7fa8154
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
name: Publish
on:
workflow_run:
workflows: [Build and Publish Docker Image]
types:
- completed
push:
branches:
- main

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

permissions:
contents: write
pull-requests: write

jobs:
publish:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
create-release-or-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -32,6 +24,6 @@ jobs:
with:
title: "Version Packages"
commit: "chore(release): version packages"
publish: pnpm changeset tag
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: "Build and Publish Docker Image"

on:
push:
branches:
- main
tags:
- "*"
release:
types:
- published

env:
REGISTRY: ghcr.io
Expand All @@ -23,44 +21,30 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "pnpm"
- run: pnpm install --frozen-lockfile

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Log in to the Container registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
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: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: github.event_name != 'pull_request'
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
Expand Down

0 comments on commit 7fa8154

Please sign in to comment.