Update README.md #2
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: Node.js build | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: # Define environment variables at the workflow level | |
PERSONAL_ACCOUNT: roborregosteam | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Create .env file | |
run: | | |
echo "DATABASE_URL=file:./db.sqlite" >> .env | |
echo "NEXTAUTH_SECRET=PiEq95e/hDuArOlgnCKRDHJs+chuUoKh/MOy4rKYBGU=" >> .env | |
echo "NEXTAUTH_URL=http://localhost:3000" >> .env | |
echo "DISCORD_CLIENT_ID=12345678" >> .env | |
echo "DISCORD_CLIENT_SECRET=12345678" >> .env | |
- run: cat .env | |
- run: npm install | |
- run: npm run build | |
check-and-fork: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Check if repo exists | |
id: check_repo | |
if: ${{ github.repository_owner != env.PERSONAL_ACCOUNT }} | |
run: | | |
REPO_NAME="${{ github.event.repository.name }}" | |
OWNER_NAME="${{ env.PERSONAL_ACCOUNT }}" | |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/${OWNER_NAME}/${REPO_NAME}) | |
if [ "$RESPONSE" -eq 404 ]; then | |
echo "Repository does not exist." | |
echo "fork_repo=true" >> $GITHUB_ENV | |
else | |
echo "Repository exists." | |
echo "fork_repo=false" >> $GITHUB_ENV | |
fi | |
- name: Fork the repository if it does not exist | |
if: env.fork_repo == 'true' | |
run: | | |
curl -L -X POST \ | |
-H "Authorization: Bearer ${{ secrets.RBRGS_TEAM_GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
https://api.github.com/repos/${{ github.repository }}/forks |