-
Notifications
You must be signed in to change notification settings - Fork 9
112 lines (107 loc) · 3.69 KB
/
republish-release.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Republish release
on:
workflow_dispatch:
inputs:
slack-channel:
required: false
type: string
description: 'The Slack channel to post to.'
default: 'metamask-snaps-deployments'
slack-icon-url:
required: false
type: string
description: 'The Slack icon URL to use.'
default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png'
slack-subteam:
required: false
type: string
description: 'The Slack subteam to mention.'
default: 'S05RL9W7H54' # @metamask-npm-publishers
slack-username:
required: false
type: string
description: 'The Slack username to use.'
default: 'MetaMask bot'
jobs:
get-release-tag:
name: Get release tag
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.get-release-tag.outputs.tag }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get release tag
id: get-release-tag
run: |
RELEASE_TAG=$(git describe --tags --abbrev=0)
echo "tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
announce-release:
name: Announce release
runs-on: ubuntu-latest
needs:
- get-release-tag
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.get-release-tag.outputs.tag }}
- id: name-version
name: Get Slack name and version
shell: bash
if: inputs.slack-subteam != ''
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
name: Get Slack final text
shell: bash
if: inputs.slack-subteam != ''
run: |
DEFAULT_TEXT="\`${{ steps.name-version.outputs.NAME_VERSION }}\` is awaiting redeployment :rocket: \n <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/|→ Click here to review deployment>"
SUBTEAM_TEXT="${{ inputs.slack-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-subteam != ''
uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844
with:
payload: |
{
"text": "${{ steps.final-text.outputs.FINAL_TEXT }}",
"icon_url": "${{ inputs.slack-icon-url }}",
"username": "${{ inputs.slack-username }}",
"channel": "#${{ inputs.slack-channel }}"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
# This is a dummy job that is used to require approval before publishing the
# release. GitHub does not allow setting environments on workflow calls, so
# we need to use a dummy job to configure the environment.
publish-release:
name: Publish release
environment: publish
runs-on: ubuntu-latest
needs:
- announce-release
steps:
- run: exit 0
publish-release-to-gh-pages:
name: Publish site to `gh-pages`
needs:
- get-release-tag
- publish-release
permissions:
contents: read
pages: write
id-token: write
uses: ./.github/workflows/publish-site.yml
with:
ref: ${{ needs.get-release-tag.outputs.tag }}
secrets:
SEGMENT_PRODUCTION_WRITE_KEY: ${{ secrets.SEGMENT_PRODUCTION_WRITE_KEY }}