Skip to content

Commit

Permalink
🔒 Security: restrict workflow context (#3124)
Browse files Browse the repository at this point in the history
Co-authored-by: polarathene <[email protected]>
  • Loading branch information
yanyongyu and polarathene authored Nov 18, 2024
1 parent 3bf3934 commit 83552d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/website-preview-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ jobs:

- name: Restore Context
run: |
cat action.env >> $GITHUB_ENV
PR_NUMBER=$(cat ./pr-number)
if ! [[ "${PR_NUMBER}" =~ ^[0-9]+$ ]]; then
echo "Invalid PR number: ${PR_NUMBER}"
exit 1
fi
echo "PR_NUMBER=${PR_NUMBER}" >> "${GITHUB_ENV}"
- name: Set Deploy Name
run: |
echo "DEPLOY_NAME=deploy-preview-${{ env.PR_NUMBER }}" >> $GITHUB_ENV
echo "DEPLOY_NAME=deploy-preview-${PR_NUMBER}" >> "${GITHUB_ENV}"
- name: Deploy to Netlify
id: deploy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/website-preview-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:

- name: Export Context
run: |
echo "PR_NUMBER=${{ github.event.number }}" >> ./action.env
echo "${{ github.event.pull_request.number }}" > ./pr-number
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: website-preview
path: |
./website/build
./action.env
./pr-number
retention-days: 1

0 comments on commit 83552d6

Please sign in to comment.