File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Node.js build
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ pull_request :
7+ branches : [ "main" ]
8+
9+ env : # Define environment variables at the workflow level
10+ PERSONAL_ACCOUNT : roborregosteam
11+
12+ jobs :
13+ check-and-fork :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v3
18+
19+ - name : Check if repo exists
20+ id : check_repo
21+ if : ${{ github.repository_owner != env.PERSONAL_ACCOUNT }}
22+ run : |
23+ REPO_NAME="${{ github.event.repository.name }}"
24+ OWNER_NAME="${{ env.PERSONAL_ACCOUNT }}"
25+ RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/${OWNER_NAME}/${REPO_NAME})
26+
27+ if [ "$RESPONSE" -eq 404 ]; then
28+ echo "Repository does not exist."
29+ echo "fork_repo=true" >> $GITHUB_ENV
30+ else
31+ echo "Repository exists."
32+ echo "fork_repo=false" >> $GITHUB_ENV
33+ fi
34+
35+ - name : Fork the repository if it does not exist
36+ if : env.fork_repo == 'true'
37+ run : |
38+ curl -L -X POST \
39+ -H "Authorization: Bearer ${{ secrets.RBRGS_TEAM_GITHUB_TOKEN }}" \
40+ -H "Accept: application/vnd.github+json" \
41+ https://api.github.com/repos/${{ github.repository }}/forks
You can’t perform that action at this time.
0 commit comments