Skip to content

Commit

Permalink
ci(test): collect environment secrets from a prepared staging environ…
Browse files Browse the repository at this point in the history
…ment (#294)
  • Loading branch information
zimeg authored Mar 14, 2024
1 parent 2a8087d commit bfb463e
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
name: Tests
on:
pull_request_target:
types: [opened, synchronize]
pull_request:
push:
branches:
- main

jobs:
# Note: The `pull_request_target` event provides access to repository secrets!
#
# This is required to run the integration tests on PRs from forked branches.
# Any job checking out pull_request.head.sha should require the access_check.
#
# Actions require collaborator approval to start and might require a re-run.
# The proposed changes should be reviewed before approving any workflow jobs.
#
# Reference: https://michaelheap.com/access-secrets-from-forks/
access_check:
runs-on: ubuntu-latest
steps:
- name: Check user permissions
if: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.author_association != 'MEMBER' }}
run: |
echo "Action was not triggered by an organization member. Exiting now."
exit 1
unit_tests:
runs-on: ubuntu-latest
needs: access_check
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm ci && npm run build
- run: npm test

integration_test_botToken:
runs-on: ubuntu-latest
needs: access_check
environment: staging
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm ci && npm run build
- name: Post message to Slack via botToken
id: slackToken
Expand Down Expand Up @@ -72,11 +48,9 @@ jobs:

integration_test_webhook:
runs-on: ubuntu-latest
needs: access_check
environment: staging
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm ci && npm run build
- run: echo "${{ github.event_name }}"
- name: push trigger
Expand Down Expand Up @@ -108,11 +82,9 @@ jobs:

integration_test_incoming_webhook:
runs-on: ubuntu-latest
needs: access_check
environment: staging
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm ci && npm run build
- run: echo "${{ github.event_name }}"
- name: Post message to Slack via incoming webhook
Expand All @@ -131,11 +103,9 @@ jobs:

integration_test_file_payload:
runs-on: ubuntu-latest
needs: access_check
environment: staging
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: npm ci && npm run build
- name: Dump out GitHub Context
run: echo $JSON
Expand Down

0 comments on commit bfb463e

Please sign in to comment.