Skip to content

Commit 93611e4

Browse files
[CI] Add workflow to build premerge-buildbot container
This patch sets up a workflow in a similar vein to all the other container images for building the premerge-buildbot container and publishing it to GHCR. There is a lot of duplicate code and eventually this should be refactored into an action. This is on my TODO list. Reviewers: cmtice Reviewed By: cmtice Pull Request: #528
1 parent 3dd019a commit 93611e4

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build Premerge Buildbot Container
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- .github/workflows/build-premerge-buildbot-container.yml
12+
- 'premerge/buildbot/**'
13+
pull_request:
14+
paths:
15+
- .github/workflows/build-premerge-buildbot-container.yml
16+
- 'premerge/buildbot/**'
17+
18+
jobs:
19+
build-premerge-buildbot-container:
20+
if: github.repository_owner == 'llvm'
21+
runs-on: ubuntu-24.04
22+
outputs:
23+
container-name: ${{ steps.vars.outputs.container-name }}
24+
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
25+
container-filename: ${{ steps.vars.outputs.container-filename }}
26+
steps:
27+
- name: Checkout LLVM Zorg
28+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
29+
with:
30+
sparse-checkout: premerge/buildbot
31+
- name: Write Variables
32+
id: vars
33+
run: |
34+
tag=`date +%s`
35+
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/premerge-buildbot"
36+
echo "container-name=$container_name" >> $GITHUB_OUTPUT
37+
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
38+
echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
39+
- name: Build Container
40+
working-directory: ./premerge/buildbot
41+
run: |
42+
podman build -t ${{ steps.vars.outputs.container-name-tag }} -f Dockerfile .
43+
# Save the container so we have it in case the push fails. This also
44+
# allows us to separate the push step into a different job so we can
45+
# maintain minimal permissions while building the container.
46+
- name: Save Container Image
47+
run: |
48+
podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
49+
- name: Upload Container Image
50+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
51+
with:
52+
name: container
53+
path: ${{ steps.vars.outputs.container-filename }}
54+
retention-days: 14
55+
56+
push-premerge-buildbot-container:
57+
if: github.event_name == 'push'
58+
needs:
59+
- build-premerge-buildbot-container
60+
permissions:
61+
packages: write
62+
runs-on: ubuntu-24.04
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
steps:
66+
- name: Download Container Image
67+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
68+
with:
69+
name: container
70+
- name: Push Container
71+
run: |
72+
podman load -i ${{ needs.build-premerge-buildbot-container.outputs.container-filename }}
73+
podman tag ${{ needs.build-premerge-buildbot-container.outputs.container-name-tag }} ${{ needs.build-premerge-buildbot-container.outputs.container-name }}:latest
74+
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
75+
podman push ${{ needs.build-premerge-buildbot-container.outputs.container-name-tag }}
76+
podman push ${{ needs.build-premerge-buildbot-container.outputs.container-name }}:latest

0 commit comments

Comments
 (0)