CI TEST #22
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Fork PR Workflow | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
jobs: | ||
create-resolve-branch: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check if PR is from a fork | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_MAIL: 41898282+github-actions[bot]@users.noreply.github.com | ||
Check failure on line 20 in .github/workflows/forked-pr.yml GitHub Actions / Fork PR WorkflowInvalid workflow file
|
||
GITHUB_NAME: github-actions[bot] | ||
run: | | ||
if [[ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]]; then | ||
echo "* PR is from a fork, continuing with workflow..." | ||
if [[ "${{ github.event.pull_request.base.ref }}" == "main" ]]; then | ||
PR_NUMBER="${{ github.event.pull_request.number }}" | ||
BRANCH_NAME="resolve/pr-${PR_NUMBER}" | ||
echo "* Cloning..." | ||
git clone https://github.com/${{ github.repository }} workspace | ||
cd workspace | ||
echo "* Creating the resolve branch..." | ||
git remote set-url origin https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | ||
git config --local user.email ${{ env.GITHUB_MAIL }} | ||
git config --local user.name ${{ env.GITHUB_NAME }} | ||
git switch main | ||
git switch -c "$BRANCH_NAME" | ||
git push origin "$BRANCH_NAME" | ||
echo "* Changing the base branch..." | ||
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-d "{\"base\": \"$BRANCH_NAME\"}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}" | ||
echo "* Assigning reviewer..." | ||
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-d '{"reviewers": ["heppokofrontend"]}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}/requested_reviewers" | ||
else | ||
echo "* PR base branch is not main, skipping workflow..." | ||
fi | ||
else | ||
echo "* PR is not from a fork, skipping workflow..." | ||
fi |