1 name: Build Metrics Container
11 - .github/workflows/build-metrics-container.yml
17 - .github/workflows/build-metrics-container.yml
21 build-metrics-container:
22 if: github.repository_owner == 'llvm'
23 runs-on: ubuntu-latest
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 }}
30 uses: actions/checkout@v4
32 sparse-checkout: .ci/metrics/
33 - name: Write Variables
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
41 - name: Build Container
42 working-directory: ./.ci/metrics
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
50 podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
51 - name: Upload Container Image
52 uses: actions/upload-artifact@v4
55 path: ${{ steps.vars.outputs.container-filename }}
58 push-metrics-container:
59 if: github.event_name == 'push'
61 - build-metrics-container
66 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68 - name: Download Container
69 uses: actions/download-artifact@v4
72 - name: Push Container
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