-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaction.yml
98 lines (97 loc) · 3.52 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: 'Publish to npm'
description: 'Publish the release to npm'
inputs:
npm-token:
description: 'The token used for npm publishing. If omitted the action will perform a dry run npm publish.'
required: false
npm-tag:
description: 'The npm tag to publish to. Defaults to "latest".'
required: false
default: 'latest'
slack-webhook-url:
description: 'Slack Webhook URL'
required: false
icon-url:
description: 'Url to the avatar used for the bot in Slack'
required: false
default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png'
username:
description: 'The name of the bot as it appears on Slack'
required: false
default: 'MetaMask bot'
subteam:
description: 'Use this if you want to ping a subteam of individuals on Slack using @'
required: false
channel:
description: 'The Slack channel to post in'
required: false
runs:
using: 'composite'
steps:
- id: Publish
shell: bash
run: ${{ github.action_path }}/scripts/main.sh
env:
YARN_NPM_AUTH_TOKEN: ${{ inputs.npm-token }}
PUBLISH_NPM_TAG: ${{ inputs.npm-tag }}
- id: install-pkdiff
shell: bash
run: npm i -g pkdiff
- id: generate-report
shell: bash
if: inputs.npm-token == ''
run: ${{ github.action_path }}/scripts/report.sh
- id: upload-artifact
if: inputs.npm-token == ''
uses: actions/upload-artifact@v4
with:
path: |
/tmp/*.tgz
/tmp/*.html
- id: name-version
shell: bash
if: inputs.slack-webhook-url != ''
run: |
NAME_VERSION_TEXT=$(jq --raw-output '.name + "@" + .version' package.json )
NAME_VERSION_TEXT_STRIPPED="${NAME_VERSION_TEXT#@}"
echo "NAME_VERSION=$NAME_VERSION_TEXT_STRIPPED" >> "$GITHUB_OUTPUT"
- id: final-text
shell: bash
if: inputs.slack-webhook-url != ''
run: |
DEFAULT_TEXT="\`${{ steps.name-version.outputs.NAME_VERSION }}\` is awaiting deployment :rocket: \n <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/|→ Click here to review deployment>"
SUBTEAM_TEXT="${{ inputs.subteam }}"
FINAL_TEXT="$DEFAULT_TEXT"
if [[ ! "$SUBTEAM_TEXT" == "" ]]; then
FINAL_TEXT="<!subteam^$SUBTEAM_TEXT> $DEFAULT_TEXT"
fi
echo "FINAL_TEXT=$FINAL_TEXT" >> "$GITHUB_OUTPUT"
- name: Post to a Slack channel
if: ${{ inputs.slack-webhook-url != '' && inputs.channel != '' }}
uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844
with:
payload: |
{
"text": "${{ steps.final-text.outputs.FINAL_TEXT }}",
"icon_url": "${{ inputs.icon-url }}",
"username": "${{ inputs.username }}",
"channel": "#${{ inputs.channel }}"
}
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook-url }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
continue-on-error: true
- name: Post to a default Slack channel
if: ${{ inputs.slack-webhook-url != '' && inputs.channel == '' }}
uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844
with:
payload: |
{
"text": "${{ steps.final-text.outputs.FINAL_TEXT }}",
"icon_url": "${{ inputs.icon-url }}",
"username": "${{ inputs.username }}"
}
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook-url }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
continue-on-error: true