-
Notifications
You must be signed in to change notification settings - Fork 1
80 lines (65 loc) · 2.21 KB
/
built-tag.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
name: Create a -built tag
on:
workflow_call:
inputs:
php:
default: "8.0"
required: false
type: string
node:
default: 16
required: false
type: number
jobs:
built-tag:
name: Create Built Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Clear previous vendor
shell: bash
run: rm -rf vendor && rm -rf composer.lock
- name: Check if the plugin has front-end assets
shell: bash
id: has-node-assets
run: |
[[ -f package.json ]] && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
- name: Install dependencies
uses: php-actions/composer@v6
with:
php_version: ${{ inputs.php }}
version: 2
args: --prefer-dist --no-dev
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node }}
- name: Install node dependencies (npm ci)
if: steps.has-node-assets.outputs.exists == 'true'
run: npm install
- name: Run npm build
if: steps.has-node-assets.outputs.exists == 'true'
run: npm run build
- name: Extract branch name
shell: bash
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
id: vars
- name: Push to -built tag
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILT_BRANCH: '${{ steps.vars.outputs.tag }}-built'
TAG_NAME: '${{ steps.vars.outputs.tag }}-built'
run: |
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config --global user.name "$GITHUB_ACTOR"
rm -rf .gitignore docker_tag output.log .github
if [[ -e "$GITHUB_WORKSPACE/.deployignore" ]]; then
mv .deployignore .gitignore
elif [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then
mv .distignore .gitignore
fi
git checkout -b $BUILT_BRANCH
git add -A && git commit -m "Built changes for $TAG_NAME"
git tag -a "$TAG_NAME" -m "Build assets for $TAG_NAME"
git push origin "refs/tags/$TAG_NAME"