Skip to content

Commit

Permalink
Fix logic to publish images to ghcr
Browse files Browse the repository at this point in the history
Trigger publish via releaser workflow and build on PR events.

Bump the version to trigger build.
  • Loading branch information
masih committed Sep 24, 2023
1 parent e4d0d94 commit adac27a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 25 deletions.
71 changes: 47 additions & 24 deletions .github/workflows/publish-ghcr.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,66 @@
name: Publish
name: Container

on:
workflow_dispatch:
release:
push:
branches:
- 'main'
tags:
- 'v*'
workflow_run:
workflows: [ Releaser ]
types:
- published
- released

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
- completed
pull_request:

jobs:
build-and-push-image:
name: Container
prepare-checkout:
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
name: Prepare ref
runs-on: ubuntu-latest
outputs:
ref: ${{ github.event_name != 'workflow_run' && github.ref || steps.releaser.outputs.version }}
steps:
- name: Get Ref from releaser
id: releaser
if: github.event_name == 'workflow_run'
uses: pl-strflt/uci/.github/actions/inspect-releaser@v0.0
with:
artifacts-url: ${{ github.event.workflow_run.artifacts_url }}
publish:
name: Publish
needs: [ prepare-checkout ]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ needs.prepare-checkout.outputs.ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@v3
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=semver,pattern={{version}}
- name: Extract metadata (tags, labels) for Docker
password: ${{ github.token }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{raw}}
type=ref,event=branch
type=raw,value=${{ needs.prepare-checkout.outputs.ref }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v4
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v0.0.3"
"version": "v0.0.4"
}

0 comments on commit adac27a

Please sign in to comment.