-
Notifications
You must be signed in to change notification settings - Fork 35
157 lines (132 loc) · 4.99 KB
/
compile_extension.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Compile Extension
on:
pull_request_target:
branches: [ "main" ]
types: [opened, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
setup:
name: "Setup"
runs-on: ubuntu-latest
outputs:
extension-path: ${{ steps.extract-extension-path.outputs.path }}
steps:
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871
with:
labels: in-process
- uses: actions-ecosystem/[email protected]
with:
labels: |
author-actions-required
build-failed
invalid-manifest
moderator-review-required
tests-failed
- name: Checkout
uses: actions/[email protected]
with:
ref: "refs/pull/${{ github.event.pull_request.number }}/merge"
- name: Extract extension path
id: extract-extension-path
env:
GH_TOKEN: ${{ github.token }}
run: |
pr_paths=$(gh pr view ${{ github.event.pull_request.number }} --json files | jq '.files | map(select(.path != ".gitmodules"))')
files_count=$(jq '. | length' <<< ${pr_paths})
if [[ $files_count -gt 1 ]]
then
echo "Only one extension per pull-request is allowed!"
exit 1
elif [[ $files_count -eq 0 ]]
then
echo "No extension was found"
exit 1
fi
echo "path=$(jq -r '.[0].path' <<< ${pr_paths})" >> $GITHUB_OUTPUT
- name: Check extension path
run: echo "${{ steps.extract-extension-path.outputs.path }}"
- uses: actions-ecosystem/[email protected]
if: failure() && (steps.extract-extension-path.outcome == 'failure')
with:
labels: in-process
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871
if: failure() && (steps.extract-extension-path.outcome == 'failure')
with:
labels: author-actions-required
build:
name: "Build"
needs: [ setup ]
runs-on: ubuntu-latest
outputs:
artifact-name: ${{ steps.build_extension.outputs.artifact-name }}
artifact-path: ${{ steps.build_extension.outputs.artifact-path }}
manifest: ${{ steps.build_extension.outputs.manifest }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: "refs/pull/${{ github.event.pull_request.number }}/merge"
- name: Init Submodule
run: git submodule update --init --recursive ./${{ needs.setup.outputs.extension-path }}
- name: Build Extension
id: build_extension
uses: Macro-Deck-App/Actions/build-extension@main
with:
extension-path: ${{ needs.setup.outputs.extension-path }}
artifact-name: ${{ github.event.pull_request.number }}
- uses: actions-ecosystem/[email protected]
if: failure() && (steps.build_extension.outcome == 'failure')
with:
labels: in-process
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871
if: failure() && (steps.build_extension.outcome == 'failure')
with:
labels: |
author-actions-required
build-failed
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871
if: success()
with:
labels: moderator-review-required
- uses: actions-ecosystem/[email protected]
if: success()
with:
labels: |
in-process
deploy:
name: "Deploy"
environment: production
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871
with:
labels: approved
- uses: actions-ecosystem/[email protected]
with:
labels: moderator-review-required
- name: Download a Build Artifact
uses: actions/[email protected]
with:
name: ${{ github.event.pull_request.number }}
- name: Upload build files
id: upload-build-files
env:
AUTH_TOKEN: ${{ secrets.MACRO_DECK_API_TOKEN }}
uses: Macro-Deck-App/Actions/upload-extension@main
with:
extension-path: "${{ github.event.pull_request.number }}.zip"
api-token: ${{ env.AUTH_TOKEN }}
- name: Notify
uses: Macro-Deck-App/Actions/notify-extension@main
with:
upload-response: ${{ steps.upload-build-files.outputs.response }}
bot-token: ${{ secrets.BOT_TOKEN }}
- name: Merge Pull Request
uses: "pascalgn/[email protected]"
env:
MERGE_LABELS: ""
PULL_REQUEST: ${{ steps.create-pr.outputs.pull-request-number}}
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"