Skip to content

Commit

Permalink
🔒 Security: restrict workflow context
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 17, 2024
1 parent abe90c0 commit 7147fe2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/website-preview-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,18 @@ 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
env:
PR_NUMBER: ${{ env.PR_NUMBER }}

- 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 7147fe2

Please sign in to comment.