Skip to content

Dont use exec script #4

Dont use exec script

Dont use exec script #4

Workflow file for this run

name: Test
on:
workflow_dispatch:
pull_request_target:
types:
- opened
- synchronize
push:
branches:
- main
- ci/setup-gh-actions
jobs:
authorize:
name: Authorize
environment: ${{ github.actor != 'dependabot[bot]' && github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true
sample:
needs: authorize
name: Test Sample
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Checkout Tests
uses: actions/checkout@v4
with:
repository: auth0-samples/api-quickstarts-tests
path: tests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup sample .env
working-directory: 01-Authorization-RS256
env:
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
API_IDENTIFIER: ${{ secrets.AUTH0_AUDIENCE }}
run: |
sed \
-e "s|{DOMAIN}|$AUTH0_DOMAIN|g" \
-e "s|{API_IDENTIFIER}|$API_IDENTIFIER|g" \
.env.example > .env
- name: Build PR image
working-directory: 01-Authorization-RS256
env:
IMAGE_NAME: ${{ github.event.pull_request.head.sha || github.sha }}
CONTAINER_NAME: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
docker build -t $IMAGE_NAME .
docker run -d --env-file .env -p 3010:3010 $CONTAINER_NAME $IMAGE_NAME
- name: Wait for sample to start
run: |
sleep 10
docker run --network host --rm appropriate/curl --retry 8 --retry-connrefused -v localhost:3010
- name: Setup tests .env
working-directory: tests
env:
AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }}
API_IDENTIFIER: ${{ secrets.API_IDENTIFIER }}
AUTH0_CLIENT_ID_1: ${{ secrets.AUTH0_CLIENT_ID_1 }} # No scopes
AUTH0_CLIENT_SECRET_1: ${{ secrets.AUTH0_CLIENT_SECRET_1 }}
AUTH0_CLIENT_ID_2: ${{ secrets.AUTH0_CLIENT_ID_2 }} # Read scope
AUTH0_CLIENT_SECRET_2: ${{ secrets.AUTH0_CLIENT_SECRET_2 }}
AUTH0_CLIENT_ID_3: ${{ secrets.AUTH0_CLIENT_ID_3 }} # Wrte scope
AUTH0_CLIENT_SECRET_3: ${{ secrets.AUTH0_CLIENT_SECRET_3 }}
AUTH0_CLIENT_ID_4: ${{ secrets.AUTH0_CLIENT_ID_4 }} # Read/write scope
AUTH0_CLIENT_SECRET_4: ${{ secrets.AUTH0_CLIENT_SECRET_4 }}
run: |
sed \
-e "s|{DOMAIN}|$AUTH0_TEST_DOMAIN|g" \
-e "s|{CLIENT_ID}|$AUTH0_TEST_CLIENT_ID|g" \
-e "s|{API_ID}|$AUTH0_TEST_API_IDENTIFIER|g" \
-e "s|{CLIENT_ID_1}|$AUTH0_CLIENT_ID_1|g" \
-e "s|{CLIENT_SECRET_1}|$AUTH0_CLIENT_SECRET_1|g" \
-e "s|{CLIENT_ID_2}|$AUTH0_CLIENT_ID_2|g" \
-e "s|{CLIENT_SECRET_2}|$AUTH0_CLIENT_SECRET_2|g" \
-e "s|{CLIENT_ID_3}|$AUTH0_CLIENT_ID_3|g" \
-e "s|{CLIENT_SECRET_3}|$AUTH0_CLIENT_SECRET_3|g" \
-e "s|{CLIENT_ID_4}|$AUTH0_CLIENT_ID_4|g" \
-e "s|{CLIENT_SECRET_4}|$AUTH0_CLIENT_SECRET_4|g" \
.env.example > .env
- name: Install dependencies
working-directory: tests
run: npm i
- name: Run tests
working-directory: tests
run: npm test