Skip to content

Commit 0f615dc

Browse files
[Github] Make metrics container build use common actions (#168667)
This patch makes the metrics container build/push job use the common container build/push actions to simplify the workflow by quite a bit.
1 parent 8ab7b60 commit 0f615dc

File tree

1 file changed

+15
-37
lines changed

1 file changed

+15
-37
lines changed

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

Lines changed: 15 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,19 @@ jobs:
2121
build-metrics-container:
2222
if: github.repository_owner == 'llvm'
2323
runs-on: ubuntu-24.04
24-
outputs:
25-
container-name: ${{ steps.vars.outputs.container-name }}
26-
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
27-
container-filename: ${{ steps.vars.outputs.container-filename }}
2824
steps:
2925
- name: Checkout LLVM
3026
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3127
with:
32-
sparse-checkout: .ci/metrics/
33-
- name: Write Variables
34-
id: vars
35-
run: |
36-
tag=`date +%s`
37-
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/metrics"
38-
echo "container-name=$container_name" >> $GITHUB_OUTPUT
39-
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
40-
echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
28+
sparse-checkout: |
29+
.ci/metrics/
30+
.github/actions/build-container
4131
- name: Build Container
42-
working-directory: ./.ci/metrics
43-
run: |
44-
podman build -t ${{ steps.vars.outputs.container-name-tag }} -f Dockerfile .
45-
# Save the container so we have it in case the push fails. This also
46-
# allows us to separate the push step into a different job so we can
47-
# maintain minimal permissions while building the container.
48-
- name: Save Container Image
49-
run: |
50-
podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
51-
- name: Upload Container Image
52-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
32+
uses: ./.github/actions/build-container
5333
with:
54-
name: container
55-
path: ${{ steps.vars.outputs.container-filename }}
56-
retention-days: 14
34+
container-name: metrics
35+
context: .ci/metrics
36+
dockerfile: .ci/metrics/Dockerfile
5737

5838
push-metrics-container:
5939
if: github.event_name == 'push'
@@ -65,14 +45,12 @@ jobs:
6545
env:
6646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6747
steps:
68-
- name: Download Container
69-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
48+
- name: Checkout LLVM
49+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
50+
with:
51+
sparse-checkout: |
52+
.github/actions/push-container
53+
54+
- uses: ./.github/actions/push-container
7055
with:
71-
name: container
72-
- name: Push Container
73-
run: |
74-
podman load -i ${{ needs.build-metrics-container.outputs.container-filename }}
75-
podman tag ${{ needs.build-metrics-container.outputs.container-name-tag }} ${{ needs.build-metrics-container.outputs.container-name }}:latest
76-
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
77-
podman push ${{ needs.build-metrics-container.outputs.container-name-tag }}
78-
podman push ${{ needs.build-metrics-container.outputs.container-name }}:latest
56+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)