Skip to content

Commit 900da3e

Browse files
committed
docs: Restrict webhook url usage
Setting the env globally was convenient but it meant that all jobs had access to that variable.
1 parent 3c26c48 commit 900da3e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ on:
6565
pull_request:
6666
branches:
6767
- master
68-
69-
env:
70-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
7168

7269
jobs:
7370
test:
@@ -79,25 +76,25 @@ jobs:
7976
- run: npm install
8077
- run: npm test
8178

82-
- name: Notify
83-
uses: iRoachie/[email protected]
79+
- uses: iRoachie/[email protected]
80+
env:
81+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
8482
with:
8583
status: ${{ job.status }}
8684
if: ${{ always() }}
8785
```
8886
8987
3. Create `SLACK_WEBHOOK_URL` secret using [GitHub Action's Secret](https://developer.github.com/actions/creating-workflows/storing-secrets). You can [generate a Slack incoming webhook token from here.](https://slack.com/apps/A0F7XDUAZ-incoming-webhooks)
9088

91-
9289
## Advanced Usage
9390

94-
Here's an example with jobs that run in parallel.
91+
Here's an example with jobs that run in parallel.
9592

9693
It does a few things:
9794

98-
- Lets us know when a status check didn't succeed (failure or cancel)
99-
- If all jobs were successful, we'll send a message at the end
100-
95+
- Lets us know when a status check didn't succeed (failure or cancel)
96+
- If all jobs were successful, we'll send a message at the end
97+
10198
```yaml
10299
name: Test
103100
@@ -106,9 +103,6 @@ on:
106103
branches:
107104
- master
108105
109-
env:
110-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
111-
112106
jobs:
113107
test:
114108
name: Jest
@@ -118,6 +112,8 @@ jobs:
118112
- run: yarn
119113
- run: yarn test
120114
- uses: iRoachie/[email protected]
115+
env:
116+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
121117
with:
122118
status: ${{ job.status }}
123119
if: ${{ !success() }}
@@ -130,6 +126,8 @@ jobs:
130126
- run: yarn
131127
- run: yarn lint
132128
- uses: iRoachie/[email protected]
129+
env:
130+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
133131
with:
134132
status: ${{ job.status }}
135133
if: ${{ !success() }}
@@ -140,6 +138,8 @@ jobs:
140138
runs-on: ubuntu-latest
141139
steps:
142140
- uses: iRoachie/[email protected]
141+
env:
142+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
143143
with:
144144
status: ${{ job.status }}
145145
```

0 commit comments

Comments
 (0)