Skip to content

Commit 1ba6d13

Browse files
[CI] Make Container Build Jobs use LLVM Actions (#649)
Some common actions in llvm/llvm-project#166663 were recently introduced to make building and pushing containers much simpler. Migrate the jobs in zorg to use them to avoid the duplication.
1 parent 0f4c50a commit 1ba6d13

File tree

3 files changed

+15
-108
lines changed

3 files changed

+15
-108
lines changed

.github/workflows/build-operations-metrics-container.yml

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,16 @@ jobs:
1919
build-operations-metrics-container:
2020
if: github.repository_owner == 'llvm'
2121
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 }}
2622
steps:
2723
- name: Checkout LLVM Zorg
2824
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2925
with:
3026
sparse-checkout: premerge/ops-container
31-
- name: Write Variables
32-
id: vars
33-
run: |
34-
tag=`date +%s`
35-
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/operations-metrics"
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
3927
- name: Build Container
40-
working-directory: premerge/ops-container
41-
run: |
42-
podman build -t ${{ steps.vars.outputs.container-name-tag }} .
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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
28+
uses: llvm/llvm-project/.github/actions/build-container@883aa1207e0319362f9b9907158520d28f45fb72
5129
with:
52-
name: container
53-
path: ${{ steps.vars.outputs.container-filename }}
54-
retention-days: 14
30+
container-name: operations-metrics
31+
context: premerge/ops-container
5532

5633
push-operations-metrics-container:
5734
if: github.event_name == 'push'
@@ -63,14 +40,6 @@ jobs:
6340
env:
6441
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6542
steps:
66-
- name: Download Container Image
67-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
43+
- uses: llvm/llvm-project/.github/actions/push-container@883aa1207e0319362f9b9907158520d28f45fb72
6844
with:
69-
name: container
70-
- name: Push Container
71-
run: |
72-
podman load -i ${{ needs.build-operations-metrics-container.outputs.container-filename }}
73-
podman tag ${{ needs.build-operations-metrics-container.outputs.container-name-tag }} ${{ needs.build-operations-metrics-container.outputs.container-name }}:latest
74-
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
75-
podman push ${{ needs.build-operations-metrics-container.outputs.container-name-tag }}
76-
podman push ${{ needs.build-operations-metrics-container.outputs.container-name }}:latest
45+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-premerge-advisor-container.yml

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,16 @@ jobs:
1919
build-premerge-advisor-container:
2020
if: github.repository_owner == 'llvm'
2121
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 }}
2622
steps:
2723
- name: Checkout LLVM Zorg
2824
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2925
with:
3026
sparse-checkout: premerge/advisor
31-
- name: Write Variables
32-
id: vars
33-
run: |
34-
tag=`date +%s`
35-
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/premerge-advisor"
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
3927
- name: Build Container
40-
working-directory: premerge/advisor
41-
run: |
42-
podman build -t ${{ steps.vars.outputs.container-name-tag }} .
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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
28+
uses: llvm/llvm-project/.github/actions/build-container@883aa1207e0319362f9b9907158520d28f45fb72
5129
with:
52-
name: container
53-
path: ${{ steps.vars.outputs.container-filename }}
54-
retention-days: 14
30+
container-name: premerge-advisor
31+
context: premerge/advisor
5532

5633
push-premerge-advisor-container:
5734
if: github.event_name == 'push'
@@ -63,14 +40,6 @@ jobs:
6340
env:
6441
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6542
steps:
66-
- name: Download Container Image
67-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
43+
- uses: llvm/llvm-project/.github/actions/push-container@883aa1207e0319362f9b9907158520d28f45fb72
6844
with:
69-
name: container
70-
- name: Push Container
71-
run: |
72-
podman load -i ${{ needs.build-premerge-advisor-container.outputs.container-filename }}
73-
podman tag ${{ needs.build-premerge-advisor-container.outputs.container-name-tag }} ${{ needs.build-premerge-advisor-container.outputs.container-name }}:latest
74-
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
75-
podman push ${{ needs.build-premerge-advisor-container.outputs.container-name-tag }}
76-
podman push ${{ needs.build-premerge-advisor-container.outputs.container-name }}:latest
45+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/build-premerge-buildbot-container.yml

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,16 @@ jobs:
1919
build-premerge-buildbot-container:
2020
if: github.repository_owner == 'llvm'
2121
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 }}
2622
steps:
2723
- name: Checkout LLVM Zorg
2824
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2925
with:
3026
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
3927
- 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@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
28+
uses: llvm/llvm-project/.github/actions/build-container@e30dc12640a21a0c25a4ca60e30fb56a6745a57b
5129
with:
52-
name: container
53-
path: ${{ steps.vars.outputs.container-filename }}
54-
retention-days: 14
30+
container-name: premerge-buildbot
31+
context: premerge/buildbot
5532

5633
push-premerge-buildbot-container:
5734
if: github.event_name == 'push'
@@ -63,14 +40,6 @@ jobs:
6340
env:
6441
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6542
steps:
66-
- name: Download Container Image
67-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
43+
- uses: llvm/llvm-project/.github/actions/push-container@e30dc12640a21a0c25a4ca60e30fb56a6745a57b
6844
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
45+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)