@@ -46,97 +46,11 @@ jobs:
46
46
build :
47
47
needs : meta
48
48
49
- runs-on : ubuntu-latest
50
-
51
- outputs :
52
- current-version : ${{ steps.current-version.outputs.value }}
53
-
54
- permissions :
55
- id-token : write
56
- contents : read
57
- attestations : write
58
- packages : write
59
-
60
- steps :
61
- - uses : actions/checkout@v4
62
- with :
63
- persist-credentials : false
64
-
65
- - name : Install bowtie
66
- uses : bowtie-json-schema/bowtie@main
67
-
68
- - name : Build
69
- id : build_image
70
- uses : redhat-actions/buildah-build@v2
71
- with :
72
- context : ' .'
73
- containerfiles : |
74
- Dockerfile
75
- image : ${{ needs.meta.outputs.implementation-name }}
76
- tags : ${{ github.sha }} ${{ github.ref == 'refs/heads/main' && 'latest' || '' }}
77
- archs : amd64, arm64
78
-
79
- - name : Set DOCKER_HOST so podman-built images are findable
80
- run : |
81
- systemctl --user enable --now podman.socket
82
- sudo loginctl enable-linger $USER
83
- podman --remote info
84
- echo "DOCKER_HOST=unix://$(podman info --format '{{.Host.RemoteSocket.Path}}')" >> $GITHUB_ENV
85
-
86
- - name : Smoke Test
87
- env :
88
- IMAGE_WITH_TAG : ${{ steps.build_image.outputs.image-with-tag }}
89
- run : |
90
- bowtie smoke -i "localhost/${IMAGE_WITH_TAG}" --format json
91
- bowtie smoke -i "localhost/${IMAGE_WITH_TAG}" --format markdown >> $GITHUB_STEP_SUMMARY
92
-
93
- - name : Collect current version
94
- id : current-version
95
- env :
96
- IMAGE_WITH_TAG : ${{ steps.build_image.outputs.image-with-tag }}
97
- run : |
98
- version=$(bowtie info \
99
- --implementation "localhost/${IMAGE_WITH_TAG}" \
100
- --format json | jq -r '.version // empty')
101
- echo "value=${version}" >> $GITHUB_OUTPUT
102
-
103
- - name : Print collected versions
104
- env :
105
- LATEST_VERSION : ${{ needs.meta.outputs.latest-version }}
106
- CURRENT_VERSION : ${{ steps.current-version.outputs.value }}
107
- run : echo "latest_version=${LATEST_VERSION}; current_version=${CURRENT_VERSION}"
108
-
109
- - name : Log in to ghcr.io
110
- uses : redhat-actions/podman-login@v1
111
- with :
112
- username : ${{ github.actor }}
113
- password : ${{ github.token }}
114
- registry : ${{ env.IMAGE_REGISTRY }}
115
- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
116
-
117
- - name : Add tag with version to the image
118
- env :
119
- IMAGE_WITH_TAG : ${{ steps.build_image.outputs.image-with-tag }}
120
- IMAGE_WITH_VERSION : " ${{ steps.build_image.outputs.image }}:${{ steps.current-version.outputs.value }}"
121
- run : podman tag ${IMAGE_WITH_TAG} ${IMAGE_WITH_VERSION}
122
- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
123
-
124
- - name : Publish
125
- id : push
126
- uses : redhat-actions/push-to-registry@v2
127
- with :
128
- image : ${{ steps.build_image.outputs.image }}
129
- tags : ${{ steps.current-version.outputs.value }} ${{ steps.build_image.outputs.tags }}
130
- registry : ${{ env.IMAGE_REGISTRY }}
131
- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
132
-
133
- - name : Generate attestation for images
134
- uses : actions/attest-build-provenance@v2
135
- with :
136
- subject-name : ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}
137
- subject-digest : ${{ steps.push.outputs.digest }}
138
- push-to-registry : true
139
- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
49
+ uses : ./.github/workflows/build-image.yml
50
+ with :
51
+ image-name : ${{ needs.meta.outputs.implementation-name }}
52
+ is-latest : ${{ github.ref == 'refs/heads/main' }}
53
+ publish-image : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
140
54
141
55
mark-previous-version :
142
56
needs : [build, meta, automerge]
@@ -192,3 +106,14 @@ jobs:
192
106
env :
193
107
PR_URL : ${{ github.event.pull_request.html_url }}
194
108
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
109
+
110
+ # Job is required to automatically publish an image for successfully merged dependabot's PR.
111
+ # PR is merged with GITHUB_TOKEN and it does not trigger the workflow run on 'push'
112
+ publish-on-automerge :
113
+ needs : [meta, automerge]
114
+
115
+ uses : ./.github/workflows/build-image.yml
116
+ with :
117
+ image-name : ${{ needs.meta.outputs.implementation-name }}
118
+ is-latest : ${{ github.event.pull_request.base.ref == 'main' }}
119
+ publish-image : true
0 commit comments