Skip to content

Commit 584a9d4

Browse files
authored
Create web-build.yml
1 parent 5ec4807 commit 584a9d4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/web-build.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

0 commit comments

Comments
 (0)