-
Notifications
You must be signed in to change notification settings - Fork 953
106 lines (92 loc) · 3.2 KB
/
build-zip.yml
File metadata and controls
106 lines (92 loc) · 3.2 KB
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
name: Build Plugin Zip
on:
workflow_dispatch:
issue_comment:
types: [created]
jobs:
build:
name: "Build plugin zip"
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/build-zip')
)
steps:
- name: Check actions access
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: context.payload.comment.user.login
});
if (!['admin', 'maintain', 'write', 'triage'].includes(data.role_name)) {
core.setFailed(`User ${context.payload.comment.user.login} does not have actions access.`);
}
- name: Add reaction to command
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
});
- name: Get PR head ref
if: github.event_name == 'issue_comment'
id: pr
uses: actions/github-script@v7
with:
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
core.setOutput('ref', pr.head.ref);
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ steps.pr.outputs.ref || '' }}
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
coverage: none
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: './.nvmrc'
- name: Yarn install
run: yarn install
- name: "Grunt: create artifact"
run: grunt artifact
- name: Set timestamp
id: timestamp
run: echo "value=$(date +'%Y%m%d-%H%M%S')" >> "$GITHUB_OUTPUT"
- name: Rename artifact folder
run: mv artifact wordpress-seo
- name: Upload zip
uses: actions/upload-artifact@v4
with:
name: wordpress-seo-${{ steps.timestamp.outputs.value }}
path: wordpress-seo/
retention-days: 1
- name: Post artifact link
if: github.event_name == 'issue_comment'
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `📦 Plugin zip built successfully!\n\nDownload it from the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).`
});