Check Upstream #245
This file contains hidden or 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: Check Upstream | |
| on: | |
| schedule: | |
| - cron: "42 3 * * *" # Run workflow every day at 3:42am UTC | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check_upstream: | |
| name: Check Upstream | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Pull Upstream Docker image 1 | |
| run: docker pull mcr.microsoft.com/powershell:latest | |
| - name: Pull Upstream Docker image 2 | |
| run: docker pull arm64v8/debian:bookworm | |
| - name: Restore upstream image digest | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: upstream-image-digest.txt | |
| key: upstream-image-digest- | |
| continue-on-error: true | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull Our Docker image | |
| run: docker pull ghcr.io/workoho/azauto-common-runbook-fw:latest | |
| - name: Check upstreams for changes | |
| id: check_upstreams | |
| run: | | |
| : > fd3output.txt | |
| exec 3> >(tee fd3output.txt) | |
| ./scripts/check-upstreams.sh mcr.microsoft.com/powershell:latest,arm64v8/debian:bookworm ghcr.io/workoho/azauto-common-runbook-fw:latest 'Az' 'Microsoft.Graph' 'ExchangeOnlineManagement' 'PnP.PowerShell' | |
| if [[ -n "$(cat fd3output.txt)" ]]; then | |
| echo -e "\e[31mChanges detected in upstreams.\e[0m" | |
| echo "HAS_CHANGES=true" >> $GITHUB_ENV | |
| else | |
| echo -e "\e[32mNo changes detected in upstreams.\e[0m" | |
| echo "HAS_CHANGES=false" >> $GITHUB_ENV | |
| fi | |
| - name: Cache upstream image digest | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: upstream-image-digest.txt | |
| key: upstream-image-digest-${{ github.run_number }} | |
| - name: Dispatch build event | |
| env: | |
| HAS_CHANGES: ${{ env.HAS_CHANGES }} | |
| if: env.HAS_CHANGES == 'true' | |
| uses: peter-evans/repository-dispatch@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| repository: ${{ github.repository }} | |
| event-type: upstream-changed |