Save master state in workflow

This commit is contained in:
Dan Balasescu 2024-10-07 18:27:28 +09:00
parent fe97f15e95
commit 639caf167d
No known key found for this signature in database
1 changed files with 25 additions and 2 deletions

View File

@ -104,6 +104,25 @@ env:
EXECUTION_ID: execution-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }} EXECUTION_ID: execution-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
jobs: 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: check-permissions:
name: Check permissions name: Check permissions
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -121,7 +140,7 @@ jobs:
create-comment: create-comment:
name: Create PR comment name: Create PR comment
needs: check-permissions needs: [ master-environment, check-permissions ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }} if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }}
steps: steps:
@ -158,7 +177,7 @@ jobs:
environment: environment:
name: Setup environment name: Setup environment
needs: directory needs: [ master-environment, directory ]
runs-on: self-hosted runs-on: self-hosted
env: env:
VARS_JSON: ${{ toJSON(vars) }} VARS_JSON: ${{ toJSON(vars) }}
@ -182,6 +201,10 @@ jobs:
fi fi
done 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 - name: Add pull-request environment
if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }} if: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request }}
run: | run: |