-
Notifications
You must be signed in to change notification settings - Fork 25
96 lines (82 loc) · 3.02 KB
/
sync-local-fallback-files.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
name: Sync runtime local fallback files
on:
schedule:
# https://crontab.guru/once-a-week
- cron: 0 0 * * 0
jobs:
sync-local-fallback-files:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: main
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: dom, iconv, json, libxml, zip
tools: composer
- name: Get Composer Cache Directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Configure Composer cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install
- name: Configure git user
run: |
git config --global user.email "[email protected]"
git config --global user.name "Alain Schlesser"
- name: Check if remote branch exists
id: remote-branch
run: echo ::set-output name=exists::$([[ -z $(git ls-remote --heads origin sync-local-fallback-files) ]] && echo "0" || echo "1")
- name: Create branch to base pull request on
if: steps.remote-branch.outputs.exists == 0
run: |
git checkout -b sync-local-fallback-files
- name: Fetch existing branch to add commits to
if: steps.remote-branch.outputs.exists == 1
run: |
git fetch --all --prune
git checkout sync-local-fallback-files
git pull --no-rebase
- name: Sync local fallback files
run: composer sync-fallback-files
- name: Check if there are changes
id: changes
run: echo ::set-output name=changed::$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")
- name: Get pull request body text
if: steps.changes.outputs.changed == 1
id: body
run: |
BODY=$(bin/render-pr-body.bash)
echo $BODY
BODY="${BODY//$'\n'/'%0A'}"
BODY="${BODY//$'`'/'\`'}"
echo -e "::set-output name=text::$BODY"
- name: Commit changes
if: steps.changes.outputs.changed == 1
run: |
git add --all .
git commit -m "Sync local fallback files - $(date +'%Y-%m-%d')"
git push origin sync-local-fallback-files
- name: Create pull request
if: |
steps.changes.outputs.changed == 1 &&
steps.remote-branch.outputs.exists == 0
uses: repo-sync/pull-request@v2
with:
source_branch: sync-local-fallback-files
destination_branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: Sync local fallback files
pr_body: ${{ steps.body.outputs.text }}
pr_reviewer: schlessera
pr_label: SSR