Skip to content

Commit

Permalink
ci: trigger docker on release
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Apr 22, 2024
1 parent 4ad3485 commit 75b34a5
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
name: Create and publish a Docker image

on:
workflow_dispatch:
push:
branches: ['main', 'staging']
tags: ['v*']
workflow_run:
workflows: [Releaser]
types:
- completed

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

jobs:
prepare_checkout:
if: (
github.repository == 'ipfs/someguy'
|| github.event_name == 'workflow_dispatch'
) && (
github.event_name != 'workflow_run'
|| github.event.workflow_run.conclusion == 'success'
)
name: Decide what ref to check out
runs-on: ubuntu-latest
outputs:
ref: ${{ github.event_name != 'workflow_run' && github.ref || steps.releaser.outputs.version }}
steps:
- name: Inspect triggering Releaser workflow run
id: releaser
if: github.event_name == 'workflow_run'
uses: ipdxco/unified-github-workflows/.github/actions/inspect-releaser@v1.0
with:
artifacts-url: ${{ github.event.workflow_run.artifacts_url }}
build-and-push-image:
needs: [prepare_checkout]
if: needs.prepare_checkout.outputs.ref != ''
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare_checkout.outputs.ref }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

Expand All @@ -43,7 +72,7 @@ jobs:
IMAGE_NAME: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
run: |
echo "value<<EOF" >> $GITHUB_OUTPUT
./.github/scripts/get-docker-tags.sh "$(date -u +%F)" >> $GITHUB_OUTPUT
./docker/get-docker-tags.sh "$(date -u +%F)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
shell: bash
- name: Build Docker image and publish to Docker Hub
Expand Down

0 comments on commit 75b34a5

Please sign in to comment.