Skip to content

Commit

Permalink
chore: update GitHub actions examples (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanjudis authored Jul 26, 2023
1 parent a0604a7 commit 3f86e8f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 30 deletions.
35 changes: 23 additions & 12 deletions examples/advanced-project-js/.github/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,34 @@
# with providers like Vercel, Heroku and others. This workflow does the following
#
# - Runs after deployment event
# - Uses the target_url provided in the deployment event
# - Uses the environment_url provided in the deployment event
# - Dry run all the checks on Checkly
# - If the dry run passes, deploy the checks.
#
# You can of course trigger the Checkly CLI in other workflows or steps inside your GH Action configuration.
name: checkly
name: 'checkly'
on: [deployment_status]

# Set the necessary credentials and export variables we can use to instrument our test run. Use the ENVIRONMENT_URL
# to run your checks against staging, preview or production.
env:
ENVIRONMENT_URL: ${{ github.event.deployment_status.target_url }}
CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }}
CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }}
ENVIRONMENT_URL: ${{ github.event.deployment_status.environment_url }}
CHECKLY_TEST_ENVIRONMENT: ${{ github.event.deployment_status.environment }}
jobs:
test-e2e:
if: github.event.deployment_status.state == 'success'
if: github.event.deployment_status.state == 'success' # Only run when the deployment was successful.
name: Test E2E on Checkly
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
with:
ref: '${{ github.event.deployment_status.deployment.ref }}'
fetch-depth: 0
- name: Set branch name # this is workaround to get the branch name.
run: echo "CHECKLY_TEST_REPO_BRANCH=$(git show -s --pretty=%D HEAD | tr -s ',' '\n' | sed 's/^ //' | grep -e 'origin/' | head -1 | sed 's/\origin\///g')" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
Expand All @@ -32,12 +42,13 @@ jobs:
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Run checks
- name: Run checks # run the checks passing in the ENVIRONMENT_URL and recording a test session.
id: run-checks
run: npm run checkly:test -- -e ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }}
continue-on-error: false
- name: Deploy checks
if: steps.run-checks.outcome == 'success'
run: npm run checkly:deploy


run: npx checkly -v && npx checkly test -e ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }} --reporter=github --record
- name: Create summary # export the markdown report to the job summary.
id: create-summary
run: cat checkly-github-report.md > $GITHUB_STEP_SUMMARY
- name: Deploy checks # if the test run was successful and we are on Production, deploy the checks
id: deploy-checks
if: steps.run-checks.outcome == 'success' && github.event.deployment_status.environment == 'Production'
run: npx checkly deploy --force
4 changes: 1 addition & 3 deletions examples/advanced-project-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"main": "index.js",
"type": "commonjs",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"checkly:deploy": "npx checkly deploy --force",
"checkly:test": "npx checkly test"
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
Expand Down
35 changes: 23 additions & 12 deletions examples/advanced-project/.github/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,34 @@
# with providers like Vercel, Heroku and others. This workflow does the following
#
# - Runs after deployment event
# - Uses the target_url provided in the deployment event
# - Uses the environment_url provided in the deployment event
# - Dry run all the checks on Checkly
# - If the dry run passes, deploy the checks.
#
# You can of course trigger the Checkly CLI in other workflows or steps inside your GH Action configuration.
name: checkly
name: 'checkly'
on: [deployment_status]

# Set the necessary credentials and export variables we can use to instrument our test run. Use the ENVIRONMENT_URL
# to run your checks against staging, preview or production.
env:
ENVIRONMENT_URL: ${{ github.event.deployment_status.target_url }}
CHECKLY_API_KEY: ${{ secrets.CHECKLY_API_KEY }}
CHECKLY_ACCOUNT_ID: ${{ secrets.CHECKLY_ACCOUNT_ID }}
ENVIRONMENT_URL: ${{ github.event.deployment_status.environment_url }}
CHECKLY_TEST_ENVIRONMENT: ${{ github.event.deployment_status.environment }}
jobs:
test-e2e:
if: github.event.deployment_status.state == 'success'
if: github.event.deployment_status.state == 'success' # Only run when the deployment was successful.
name: Test E2E on Checkly
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
with:
ref: '${{ github.event.deployment_status.deployment.ref }}'
fetch-depth: 0
- name: Set branch name # this is workaround to get the branch name.
run: echo "CHECKLY_TEST_REPO_BRANCH=$(git show -s --pretty=%D HEAD | tr -s ',' '\n' | sed 's/^ //' | grep -e 'origin/' | head -1 | sed 's/\origin\///g')" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
Expand All @@ -32,12 +42,13 @@ jobs:
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Run checks
- name: Run checks # run the checks passing in the ENVIRONMENT_URL and recording a test session.
id: run-checks
run: npm run checkly:test -- -e ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }}
continue-on-error: false
- name: Deploy checks
if: steps.run-checks.outcome == 'success'
run: npm run checkly:deploy


run: npx checkly -v && npx checkly test -e ENVIRONMENT_URL=${{ env.ENVIRONMENT_URL }} --reporter=github --record
- name: Create summary # export the markdown report to the job summary.
id: create-summary
run: cat checkly-github-report.md > $GITHUB_STEP_SUMMARY
- name: Deploy checks # if the test run was successful and we are on Production, deploy the checks
id: deploy-checks
if: steps.run-checks.outcome == 'success' && github.event.deployment_status.environment == 'Production'
run: npx checkly deploy --force
4 changes: 1 addition & 3 deletions examples/advanced-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"main": "index.js",
"type": "commonjs",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"checkly:deploy": "npx checkly deploy --force",
"checkly:test": "npx checkly test"
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
Expand Down

0 comments on commit 3f86e8f

Please sign in to comment.