Regularly update pin targeting stable valida release #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Nigtly Valida Pin Update | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Run at midnight UTC daily | |
workflow_dispatch: | |
pull_request: | |
env: | |
CONTAINER_REGISTRY: ghcr.io | |
CONTAINER_IMAGE: lita-xyz/llvm-valida-releases/valida-build-container | |
jobs: | |
check-and-build: | |
runs-on: warp-custom-big-disk | |
permissions: | |
contents: write | |
packages: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get pinned version | |
id: get-pinned-version | |
run: | | |
PINNED_VERSION=$(cat ./valida-version-pin.txt) | |
echo "pinned_version=${PINNED_VERSION}" >> $GITHUB_OUTPUT | |
- name: Get latest container version | |
id: get-latest-version | |
run: | | |
LATEST_VERSION=$(curl -s -L -H "Accept: application/vnd.github+json" -H \ | |
"Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H \ | |
"X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/orgs/lita-xyz/packages/container/llvm-valida-releases%2Fvalida-build-container/versions" \ | |
| jq -r '.[0].metadata.container.tags[0]') | |
echo "latest_version=${LATEST_VERSION}" >> $GITHUB_OUTPUT | |
- name: Compare versions | |
id: version-check | |
run: | | |
if [ "${{ steps.get-pinned-version.outputs.pinned_version }}" = "${{ steps.get-latest-version.outputs.latest_version }}" ]; then | |
echo "versions_match=true" >> $GITHUB_OUTPUT | |
else | |
echo "versions_match=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Exit if versions match | |
if: steps.version-check.outputs.versions_match == 'true' | |
run: | | |
echo "Pinned version matches latest container version. No build needed." | |
exit 0 | |
- name: Pull latest container | |
if: steps.version-check.outputs.versions_match == 'false' | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.CONTAINER_REGISTRY }} -u ${{ github.actor }} --password-stdin | |
docker pull ${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:v0.7.0-alpha | |
- name: Run build in container | |
if: steps.version-check.outputs.versions_match == 'false' | |
id: build | |
continue-on-error: true | |
run: | | |
cd bin/host | |
docker run --rm \ | |
-v ${{ github.workspace }}:/workspace \ | |
-w /workspace \ | |
${{ env.CONTAINER_REGISTRY }}/${{ env.CONTAINER_IMAGE }}:v0.7.0-alpha \ | |
cargo +valida build --release | |
- name: Update version pin on success | |
if: steps.version-check.outputs.versions_match == 'false' && steps.build.outcome == 'success' | |
run: | | |
echo "${{ steps.get-latest-version.outputs.latest_version }}" > ./valida-version-pin.txt | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -am "Update valida version pin to ${{ steps.get-latest-version.outputs.latest_version }}" | |
git push | |
# - name: Send failure notification | |
# if: steps.version-check.outputs.versions_match == 'false' && steps.build.outcome == 'failure' | |
# uses: dawidd6/action-send-mail@v3 | |
# with: | |
# server_address: ${{ secrets.SMTP_SERVER }} | |
# server_port: ${{ secrets.SMTP_PORT }} | |
# username: ${{ secrets.SMTP_USERNAME }} | |
# password: ${{ secrets.SMTP_PASSWORD }} | |
# subject: "⚠️ Valida Build Failed for Reva" | |
# body: | | |
# The nightly Valida build check has failed. | |
# Container version: ${{ steps.get-latest-version.outputs.latest_version }} | |
# Repository: ${{ github.repository }} | |
# Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
# Please check the workflow logs for more details. | |
# to: ${{ secrets.NOTIFICATION_EMAIL }} | |
# from: GitHub Actions <${{ secrets.SMTP_USERNAME }}> |