From ccc49bf6d5245c94711bafd921a69a7fe0d69937 Mon Sep 17 00:00:00 2001 From: Tau Date: Tue, 30 Jan 2024 01:20:35 +0100 Subject: [PATCH] fix conditionals --- .github/workflows/vib-build.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/vib-build.yml b/.github/workflows/vib-build.yml index 8eb019f..3463468 100644 --- a/.github/workflows/vib-build.yml +++ b/.github/workflows/vib-build.yml @@ -20,16 +20,20 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set requirement + run: echo "CHECK_UPDATES=${{ github.event_name != 'schedule'}}" >> "$GITHUB_ENV" + - name: Install dependencies + if: env.CHECK_UPDATES run: sudo apt-get install jq - name: Download previous digest - if: github.event_name != 'schedule' + if: env.CHECK_UPDATES continue-on-error: true run: wget https://github.com/${{ github.repository }}/releases/download/${{ env.DIGEST_RELEASE_TAG }}a/digest.txt - name: Check if there was an update to the base image - if: github.event_name != 'schedule' + if: env.CHECK_UPDATES run: | touch digest.txt mv digest.txt last_digest.txt @@ -37,10 +41,9 @@ jobs: jq -r '.image.releases[-1].digest' vanilla-image-info > digest.txt echo Old digest is: $(cat last_digest.txt) echo New digest is: $(cat digest.txt) - cmp -s digest.txt last_digest.txt - echo "HAS_UPDATES=$?" >> "$GITHUB_ENV" - if [ ${{ env.HAS_UPDATES }} ]; then + if [ $(cmp -s digest.txt last_digest.txt) ]; then echo base image was updated since last build + echo "HAS_UPDATES=true" >> "$GITHUB_ENV" echo "has_updates=true" >> "$GITHUB_OUTPUT" else echo no updates to the base image since last build @@ -48,7 +51,7 @@ jobs: fi - name: Upload new digest - if: github.event_name != 'schedule' && env.HAS_UPDATES == 1 + if: env.CHECK_UPDATES && env.HAS_UPDATES == 1 uses: softprops/action-gh-release@v1 with: token: "${{ secrets.GITHUB_TOKEN }}" @@ -59,7 +62,7 @@ jobs: digest.txt - name: Update was triggered manually - if: github.event_name == 'schedule' + if: !env.CHECK_UPDATES run: | echo "has_updates=true" >> "$GITHUB_OUTPUT"