-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (61 loc) · 2.8 KB
/
pr-build-live-branch.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
name: Build Live Branch
on:
pull_request:
permissions: {}
jobs:
build:
runs-on: ubuntu-20.04
permissions:
contents: write
pull-requests: write
repository-projects: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Prepare plugin zips
id: prepare
env:
CURRENT_VERSION: ${{ steps.version.outputs.version }}
run: |
# Current version must compare greater than any previously used current version for this PR.
# Assume GH run IDs are monotonic.
VERSUFFIX="${GITHUB_RUN_ID}-g$(git rev-parse --short HEAD)"
CURRENT_VERSION="$CURRENT_VERSION-$VERSUFFIX"
cd "$GITHUB_WORKSPACE"
bash bin/build-zip.sh
mkdir "$GITHUB_WORKSPACE/zips"
mkdir -p "$GITHUB_WORKSPACE/unzips"
mv "$GITHUB_WORKSPACE/flipbox-block.zip" "$GITHUB_WORKSPACE/zips/flipbox-block.zip"
cd "$GITHUB_WORKSPACE/zips"
unzip -qq flipbox-block.zip
cp -r flipbox-block "$GITHUB_WORKSPACE/unzips/flipbox-block"
rm flipbox-block.zip
mv flipbox-block flipbox-block-dev
zip -q -r -9 "flipbox-block-dev.zip" "flipbox-block-dev/"
rm -fR "$GITHUB_WORKSPACE/zips/flipbox-block-dev"
# Plugin data is passed as a JSON object.
PLUGIN_DATA="{}"
PLUGIN_DATA=$( jq -c --arg slug "flipbox-block" --arg ver "$CURRENT_VERSION" '.[ $slug ] = { version: $ver }' <<<"$PLUGIN_DATA" )
echo "plugin-data=$PLUGIN_DATA" >> $GITHUB_OUTPUT
- name: Create plugins artifact
uses: actions/upload-artifact@v4
if: steps.prepare.outputs.plugin-data != '{}'
with:
name: plugins
path: zips
# Only need to retain for a day since the beta builder slurps it up to distribute.
retention-days: 1
- name: Create playground artifact
uses: actions/upload-artifact@v4
if: steps.prepare.outputs.plugin-data != '{}'
with:
name: plugins-${{ github.run_id }}
path: unzips/flipbox-block
retention-days: 30
- name: Comment on PR with WordPress Playground details
uses: actions/github-script@v7
if: steps.prepare.outputs.plugin-data != '{}'
with:
script: |
const { run } = require('./.github/workflows/scripts/generate-playground-blueprint');
run({ github, context, core });