Skip to content

feat: pass custom context #53

feat: pass custom context

feat: pass custom context #53

Workflow file for this run

name: pr
on: pull_request
jobs:
test:
runs-on: ubuntu-20.04
steps:
- name: Print GITHUB variables 🖨
run: npx @bahmutov/print-env GITHUB
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump GitHub event
env:
GITHUB_EVENT: ${{ toJson(github.event) }}
run: echo "$GITHUB_EVENT"
- name: Dump GitHub event pull request
env:
GITHUB_PR: ${{ toJson(github.event.pull_request) }}
run: echo "$GITHUB_PR"
- name: Print commit SHA
run: echo "Commit SHA is ${{ github.event.pull_request.head.sha }}"
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Install dependencies 📦
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
runTests: false
- name: Set the common status 🎬
run: |
node ./bin/set-gh-status --owner bahmutov --repo cypress-set-github-status \
--sha ${{ github.event.pull_request.head.sha }} --status pending \
--context "Cypress E2E tests" --description "Running tests..."
env:
# this token is not tied to any repository
# and can be used to set the commit status in the repos I have access to
PERSONAL_GH_TOKEN: ${{ secrets.PERSONAL_GH_TOKEN }}
- name: Run tests 🧪
# https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
install: false
env: 'pullRequest=${{ github.event.number }}'
env:
# this token is not tied to any repository
# and can be used to set the commit status in the repos I have access to
PERSONAL_GH_TOKEN: ${{ secrets.PERSONAL_GH_TOKEN }}
# point the plugin to update the commit status of the head commit
# TIP: we need to use an environment variable that does not start with GITHUB
# since those variables are set by the GitHub and can't be overridden
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
# use the same context as the above step
COMMON_STATUS: 'Cypress E2E tests'
COMMIT_CONTEXT: 'PR E2E'
# pretend this is the third machine our of 5
MACHINES_INDEX: 2
MACHINES_TOTAL: 5
DEBUG: cypress-set-github-status
- name: Semantic Release 🚀
if: github.ref == 'refs/heads/main'
uses: cycjimmy/semantic-release-action@v4
with:
branch: main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}