-
-
Notifications
You must be signed in to change notification settings - Fork 536
135 lines (114 loc) · 4.04 KB
/
release-check.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: 🆙 Release file check
on:
pull_request_target:
types: [synchronize, reopened, opened, ready_for_review]
branches:
- main
paths:
- "strawberry/**"
- "pyproject.toml"
jobs:
get-contributor-info:
name: Get PR info
runs-on: ubuntu-latest
outputs:
contributor-name: ${{ steps.get-info.outputs.contributor-name }}
contributor-username: ${{ steps.get-info.outputs.contributor-username }}
contributor-twitter-username: ${{ steps.get-info.outputs.contributor-twitter-username }}
steps:
- name: Get PR info
id: get-info
uses: strawberry-graphql/get-pr-info-action@v6
- run: echo "${{ steps.get-info.outputs.contributor-twitter-username }}"
skip-if-bot:
name: Set skip if PR is from a bot
runs-on: ubuntu-latest
needs: get-contributor-info
outputs:
skip: ${{ steps.skip.outputs.skip }}
steps:
- name: Set skip to true if contributor is a bot
id: skip
shell: python
run: |
bots = [
"dependabot-preview[bot]",
"dependabot-preview",
"dependabot",
"dependabot[bot]",
]
username = "${{ needs.get-contributor-info.outputs.contributor-username }}"
if username in bots:
print(f"Skipping {username} because it is a bot")
print("::set-output name=skip::true")
else:
print("::set-output name=skip::false")
release-file-check:
name: Release check
runs-on: ubuntu-latest
needs: skip-if-bot
if: needs.skip-if-bot.outputs.skip == 'false'
outputs:
changelog: ${{ steps.release-check.outputs.changelog }}
status: ${{ steps.release-check.outputs.release_status }}
change_type: ${{ steps.release-check.outputs.change_type }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: "refs/pull/${{ github.event.number }}/merge"
- name: Release file check
uses: ./.github/release-check-action
id: release-check
if: github.event.pull_request.draft == false
read-tweet-md:
name: Read TWEET.md
runs-on: ubuntu-latest
needs: [get-contributor-info, release-file-check]
outputs:
tweet: ${{ steps.extract.outputs.tweet }}
steps:
- uses: actions/checkout@v2
with:
ref: "refs/pull/${{ github.event.number }}/merge"
- name: Extract tweet message and changelog
id: extract
uses: strawberry-graphql/tweet-actions/read-tweet@v6
with:
changelog: ${{ needs.release-file-check.outputs.changelog }}
version: "(next)"
contributor_name: ${{ needs.get-contributor-info.outputs.contributor-name }}
contributor_twitter_username: ${{ needs.get-contributor-info.outputs.contributor-twitter-username }}
validate-tweet:
runs-on: ubuntu-latest
needs: read-tweet-md
if: ${{ needs.read-tweet-md.outputs.tweet != '' }}
steps:
- name: Validate tweet
uses: strawberry-graphql/tweet-actions/validate-tweet@v6
with:
tweet: ${{ needs.read-tweet-md.outputs.tweet }}
send-comment:
runs-on: ubuntu-latest
needs: [release-file-check, read-tweet-md]
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v2
- name: Send comment
uses: ./.github/bot-action
env:
BOT_API_URL: ${{ secrets.BOT_API_URL }}
API_SECRET: ${{ secrets.API_SECRET }}
with:
pr_number: ${{ github.event.number }}
status: ${{ needs.release-file-check.outputs.status }}
change_type: ${{ needs.release-file-check.outputs.change_type }}
changelog_base64: ${{ needs.release-file-check.outputs.changelog }}
tweet: ${{ needs.read-tweet-md.outputs.tweet }}
fail-if-status-is-not-ok:
runs-on: ubuntu-latest
needs: [release-file-check, send-comment]
steps:
- name: Fail if status is not ok
if: ${{ needs.release-file-check.outputs.status != 'OK' }}
run: exit 1