-
Notifications
You must be signed in to change notification settings - Fork 101
71 lines (63 loc) · 2.65 KB
/
deploy.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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Deploy
on:
push:
branches:
- "develop"
permissions:
contents: read
jobs:
deploy:
name: "Deploy"
runs-on: ubuntu-latest
if: github.ref_type == 'branch'
env:
SOURCE_REPO_PATH: main
TARGET_REPO_PATH: built
EXT_REPO_PATH: ext
permissions:
contents: write
steps:
- name: Check out the source code
uses: actions/checkout@v4.2.2
with:
submodules: recursive
path: ${{ env.SOURCE_REPO_PATH }}
- name: Check out Automattic/vip-go-mu-plugins-ext
uses: actions/checkout@v4.2.2
with:
repository: Automattic/vip-go-mu-plugins-ext
path: ${{ env.EXT_REPO_PATH }}
- name: Check out Automattic/vip-go-mu-plugins-built
uses: actions/checkout@v4.2.2
with:
repository: Automattic/vip-go-mu-plugins-built
path: ${{ env.TARGET_REPO_PATH }}
ssh-key: ${{ secrets.SSH_DEPLOY_KEY }}
- name: Configure .git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "no-reply@automattic.com"
git config push.default "current"
working-directory: ${{ env.TARGET_REPO_PATH }}
- name: Synchronize files
run: |
mv "${GITHUB_WORKSPACE}/${TARGET_REPO_PATH}/.git" "${GITHUB_WORKSPACE}/${TARGET_REPO_PATH}/../built-git-bak"
rsync --delete --delete-excluded -a "${GITHUB_WORKSPACE}/${SOURCE_REPO_PATH}/" "${GITHUB_WORKSPACE}/${EXT_REPO_PATH}/"* "${GITHUB_WORKSPACE}/${TARGET_REPO_PATH}/" --exclude-from="${GITHUB_WORKSPACE}/${SOURCE_REPO_PATH}/.dockerignore" --exclude-from="${GITHUB_WORKSPACE}/${EXT_REPO_PATH}/.dockerignore" --exclude="/jetpack-*/"
mv "${GITHUB_WORKSPACE}/${TARGET_REPO_PATH}/../built-git-bak" "${GITHUB_WORKSPACE}/${TARGET_REPO_PATH}/.git"
- name: Clean up
run: |
TARGET="${GITHUB_WORKSPACE}/${TARGET_REPO_PATH}"
find "${TARGET}" -name ".svn" -exec rm -rfv {} \; 2> /dev/null
find "${TARGET}" -name ".git*" -not -name ".github" -not -name ".git" -exec rm -rfv {} \; 2> /dev/null
cp -vf "${GITHUB_WORKSPACE}/${SOURCE_REPO_PATH}/README-PUBLIC.md" "${TARGET}/README.md"
cp -vf "${GITHUB_WORKSPACE}/${SOURCE_REPO_PATH}/composer.json.tpl" "${TARGET}/composer.json"
- name: Commit!
run: |
git add -A .
git status
if [ -n "$(git diff --stat --cached)" ]; then
git commit -am "Built from vip-go-mu-plugins@${GITHUB_SHA}"
git push
fi
working-directory: ${{ env.TARGET_REPO_PATH }}