Skip to content

Update date

Update date #100

Workflow file for this run

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: Expose github environment as shell variables
env:
SECRETS_CONTEXT: ${{ toJson(secrets) }}
# VARS_CONTEXT: ${{ toJson(vars) }}
run: |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
to_envs() { jq -r "to_entries[] | \"\(.key)<<$EOF\n\(.value)\n$EOF\n\""; }
# echo "$VARS_CONTEXT" | to_envs >> $GITHUB_ENV
echo "$SECRETS_CONTEXT" | to_envs >> $GITHUB_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