Skip to content

Commit

Permalink
refactor: move checkout after verify
Browse files Browse the repository at this point in the history
  • Loading branch information
balakrishna-deriv committed Dec 18, 2023
1 parent 8dfb662 commit 73ac871
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/generate_preview_link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ on:
types:
- completed

env:
HEAD_REF: ${{ github.head_ref }}

concurrency:
group: cloudflare-pages-build-${{ github.event.workflow_run.head_branch }}
group: cloudflare-pages-build-"$HEAD_REF"
cancel-in-progress: true

jobs:
build_and_deploy_preview_link:
runs-on: Ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
Expand All @@ -39,7 +38,18 @@ jobs:
id: pr_information
run: |
echo "username=$(cat .pr/USERNAME)" >> $GITHUB_OUTPUT
echo "issue_number=$(cat .pr/NR)" >> $GITHUB_OUTPUT
echo "issue_number=$(cat .pr/ISSUE_NUMBER)" >> $GITHUB_OUTPUT
- name: Verify user
uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1"
with:
username: ${{steps.pr_information.outputs.username}}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}

- name: Post preview build comment
id: post_preview_build_comment
Expand All @@ -48,12 +58,6 @@ jobs:
issue_number: ${{steps.pr_information.outputs.issue_number}}
head_sha: ${{github.event.workflow_run.head_sha}}

- name: Verify user
uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1"
with:
username: ${{steps.pr_information.outputs.username}}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v1
with:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/pre_generate_preview_link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ on:
pull_request:
types: [opened, synchronize]

env:
HEAD_REF: ${{ github.head_ref }}

concurrency:
group: cloudflare-pages-verify-${{ github.head_ref }}
group: cloudflare-pages-verify-"$HEAD_REF"
cancel-in-progress: true

jobs:
upload_pr_info:
runs-on: Ubuntu-latest
steps:
- name: Retrieve PR information
env:
ISSUE_NUMBER: ${{ github.event.number }}
USERNAME: ${{ github.event.pull_request.user.login }}
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
echo ${{ github.event.pull_request.user.login }} > ./pr/USERNAME
echo "$ISSUE_NUMBER" > ./pr/ISSUE_NUMBER
echo "$USERNAME" > ./pr/USERNAME
- name: Upload PR information to artifact
uses: actions/upload-artifact@v2
Expand Down

0 comments on commit 73ac871

Please sign in to comment.