Skip to content

Commit f81e909

Browse files
authored
Merge pull request #12 from bowtie-json-schema/build-after-successfull-dependabot-pr
Add workflow that is triggered after a successful dependabot PR
2 parents 8b5667c + d575322 commit f81e909

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

.github/workflows/build-image.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Build test harness image
33
on:
44
workflow_call:
55
inputs:
6-
image-name:
7-
type: string
8-
required: true
9-
description: 'Name for the image to build'
106
publish-image:
117
type: boolean
128
default: false
@@ -46,14 +42,20 @@ jobs:
4642
- name: Install bowtie
4743
uses: bowtie-json-schema/bowtie@main
4844

45+
- name: Compute implementation name
46+
id: impl
47+
env:
48+
GH_REPOSITORY: ${{ github.repository }}
49+
run: echo "name=$(echo ${GH_REPOSITORY} | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT
50+
4951
- name: Build
5052
id: build_image
5153
uses: redhat-actions/buildah-build@v2
5254
with:
5355
context: '.'
5456
containerfiles: |
5557
Dockerfile
56-
image: ${{ inputs.image-name }}
58+
image: ${{ steps.impl.outputs.name }}
5759
tags: ${{ github.sha }} ${{ inputs.is-latest && 'latest' || '' }}
5860
archs: amd64, arm64
5961

.github/workflows/build.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
runs-on: ubuntu-latest
2222
outputs:
2323
latest-version: ${{ steps.version.outputs.value }}
24-
implementation-name: ${{ steps.impl.outputs.name }}
2524
steps:
2625

2726
- name: Install bowtie
@@ -55,7 +54,6 @@ jobs:
5554

5655
uses: ./.github/workflows/build-image.yml
5756
with:
58-
image-name: ${{ needs.meta.outputs.implementation-name }}
5957
is-latest: ${{ github.ref == 'refs/heads/main' }}
6058
publish-image: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
6159

@@ -113,21 +111,3 @@ jobs:
113111
env:
114112
PR_URL: ${{ github.event.pull_request.html_url }}
115113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116-
117-
# Job is required to automatically publish an image for successfully merged dependabot's PR.
118-
# PR is merged with GITHUB_TOKEN and it does not trigger the workflow run on 'push'.
119-
# Executes only if 'automerge' is not skipped
120-
publish-on-automerge:
121-
needs: [meta, automerge]
122-
123-
permissions:
124-
id-token: write
125-
contents: read
126-
attestations: write
127-
packages: write
128-
129-
uses: ./.github/workflows/build-image.yml
130-
with:
131-
image-name: ${{ needs.meta.outputs.implementation-name }}
132-
is-latest: ${{ github.event.pull_request.base.ref == 'main' }}
133-
publish-image: true

.github/workflows/dependabot-build.yml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,30 @@ on:
44
workflow_run: # zizmor: ignore[dangerous-triggers] we are aware that it is a dengerouse trigger but we need a way to build an image after Dependabot PR
55
types: [ completed ]
66
workflows: [ 'Rebuild Bowtie Image' ]
7+
branches:
8+
- 'dependabot/**'
79

810
permissions: {}
911

12+
concurrency:
13+
# in this case if several dependabot PRs are merged only the latest one will build and publish the image
14+
group: dependabot-${{ github.event.workflow_run.event }}-${{ github.event.workflow_run.triggering_actor.login }}
15+
cancel-in-progress: true
16+
1017
jobs:
1118
build-and-publish:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Print trigger event
15-
env:
16-
EVENT_PAYLOAD: ${{ toJson(github.event) }}
17-
run: echo $EVENT_PAYLOAD
19+
if: |
20+
github.event.workflow_run.event == 'pull_request'
21+
&& github.event.workflow_run.conclusion == 'success'
22+
&& github.event.workflow_run.triggering_actor.login == 'dependabot[bot]'
23+
24+
permissions:
25+
id-token: write
26+
contents: read
27+
attestations: write
28+
packages: write
29+
30+
uses: ./.github/workflows/build-image.yml
31+
with:
32+
is-latest: true
33+
publish-image: true

0 commit comments

Comments
 (0)