[llvm-branch-commits] [llvm] [Github] Add new workflow to build metrics container (PR #117462)
Aiden Grossman via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Nov 23 21:40:25 PST 2024
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/117462
This patch adds a new Github Actions workflow to build the metrics container and push it to the Github Container Registry.
>From 0522707ac0686fdbf578c20690ebfcec3539645e Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Sun, 24 Nov 2024 05:39:03 +0000
Subject: [PATCH] [Github] Add new workflow to build metrics container
This patch adds a new Github Actions workflow to build the metrics container
and push it to the Github Container Registry.
---
.github/workflows/build-metrics-container.yml | 78 +++++++++++++++++++
1 file changed, 78 insertions(+)
create mode 100644 .github/workflows/build-metrics-container.yml
diff --git a/.github/workflows/build-metrics-container.yml b/.github/workflows/build-metrics-container.yml
new file mode 100644
index 00000000000000..2b73dc87ea9f82
--- /dev/null
+++ b/.github/workflows/build-metrics-container.yml
@@ -0,0 +1,78 @@
+name: Build Metrics Container
+
+permissions:
+ contents: read
+
+on:
+ push:
+ branches:
+ - main
+ paths:
+ - .github/workflows/build-metrics-container.yml
+ - '.ci/metrics/**'
+ pull_request:
+ branches:
+ - main
+ paths:
+ - .github/workflows/build-metrics-container.yml
+ - '.ci/metrics/**'
+
+jobs:
+ build-metrics-container:
+ if: github.repository_owner == 'llvm'
+ runs-on: ubuntu-latest
+ outputs:
+ container-name: ${{ steps.vars.outputs.container-name }}
+ container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
+ container-filename: ${{ steps.vars.outputs.container-filename }}
+ steps:
+ - name: Checkout LLVM
+ uses: actions/checkout at v4
+ with:
+ sparse-checkout: .ci/metrics/
+ - name: Write Variables
+ id: vars
+ run: |
+ tag=`date +%s`
+ container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/metrics"
+ echo "container-name=$container-name" >> $GITHUB_OUTPUT
+ echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
+ echo "container-filename=$(echo $container_name:$tag | sed -e 's/\//-/g' -e 's/:/-/g').tar" >> $GITHUB_OUTPUT
+ - name: Build Container
+ working-directory: ./.ci/metrics
+ run: |
+ podman build -t ${{ steps.vars.outputs.container-name-tag }} -f Dockerfile .
+ # Save the container so we have it in case the push fails. This also
+ # allows us to separate the push step into a different job so we can
+ # maintain minimal permissions while building the container.
+ - name: Save Container Image
+ run: |
+ podman save ${{ steps.vars.outputs.container-name-tag }} > ${{ steps.vars.outputs.container-filename }}
+ - name: Upload Container Image
+ uses: actions/upload-artifact at v4
+ with:
+ name: container
+ path: ${{ steps.vars.outputs.container-filename }}
+ retention-days: 14
+
+ push-metrics-container:
+ if: github.event_name == 'push'
+ needs:
+ - build-metrics-container
+ permissions:
+ packages: write
+ runs-on: ubuntu-24.04
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ steps:
+ - name: Download Container
+ uses: actions/download-artifact at v4
+ with:
+ name: container
+ - name: Push Container
+ run: |
+ podman load -i ${{ needs.build-metrics-container.outptus.container-filename }}
+ podman tag ${{ needs.build-metrics-container.outputs.container-name-tag }} ${{ sneeds.build-metrics-container.outputs.container-name }}:latest
+ podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
+ podman push ${{ needs.build-metrics-container.outputs.container-name-tag }}
+ podman push ${{ needs.build-metrics-container.outputs.container-name }}:latest
More information about the llvm-branch-commits
mailing list