From 639caf167df19a6390922e4cdd3cd4799c09d979 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 7 Oct 2024 18:27:28 +0900 Subject: [PATCH] Save master state in workflow --- .github/workflows/diffcalc.yml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/diffcalc.yml b/.github/workflows/diffcalc.yml index 7fb0709decab..ebf22b8a0e2f 100644 --- a/.github/workflows/diffcalc.yml +++ b/.github/workflows/diffcalc.yml @@ -104,6 +104,25 @@ env: EXECUTION_ID: execution-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }} jobs: + master-environment: + name: Save master environment + runs-on: ubuntu-latest + outputs: + HEAD: ${{ steps.get-head.outputs.HEAD }} + steps: + - name: Checkout osu + uses: actions/checkout@v4 + with: + ref: master + sparse-checkout: | + README.md + + - name: Get HEAD ref + id: get-head + run: | + ref=$(git log -1 --format='%H') + echo "HEAD=https://github.com/${{ github.repository }}/commit/${ref}" >> "${GITHUB_OUTPUT}" + check-permissions: name: Check permissions runs-on: ubuntu-latest @@ -121,7 +140,7 @@ jobs: create-comment: name: Create PR comment - needs: check-permissions + needs: [ master-environment, check-permissions ] runs-on: ubuntu-latest if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }} steps: @@ -158,7 +177,7 @@ jobs: environment: name: Setup environment - needs: directory + needs: [ master-environment, directory ] runs-on: self-hosted env: VARS_JSON: ${{ toJSON(vars) }} @@ -182,6 +201,10 @@ jobs: fi done + - name: Add master environment + run: | + sed -i "s;^OSU_A=.*$;OSU_A=${{ needs.master-environment.outputs.HEAD }};" "${{ needs.directory.outputs.GENERATOR_ENV }}" + - name: Add pull-request environment if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }} run: |