-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathremote-cron.yml
More file actions
80 lines (70 loc) · 2.55 KB
/
remote-cron.yml
File metadata and controls
80 lines (70 loc) · 2.55 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
name: Remote Cron Task
on:
push:
branches: [feature/cron]
# schedule:
# # * is a special character in YAML so you have to quote this string
# - cron: '*/15 * * * *'
jobs:
execute_cron:
runs-on: ubuntu-latest
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
SITE_ID: ${{ secrets.PANTHEON_SITE_ID }}
TERMINUS_MACHINE_TOKEN: ${{ secrets.TERMINUS_MACHINE_TOKEN }}
steps:
- name: Installing PHP
uses: shivammathur/setup-php@2.4.2
with:
php-version: '7.4'
coverage: none
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2.0.3
with:
key: ${{ secrets.PRIVATE_SSH_KEY }}
known_hosts: drush.in
- name: Add known hosts
run: |
APP_SERVER=$(echo "appserver.dev.${SITE_ID}.drush.in")
CODE_SERVER=$(echo "codeserver.dev.${SITE_ID}.drush.in")
ssh-keyscan -t rsa -p 2222 $APP_SERVER >> ~/.ssh/known_hosts
ssh-keyscan -t rsa -p 2222 $CODE_SERVER >> ~/.ssh/known_hosts
- name: Clone Pantheon site repo, set to live tag
id: clone-pantheon-site
run: |
REMOTE=$(echo "ssh://codeserver.dev.${SITE_ID}@codeserver.dev.${SITE_ID}.drush.in:2222/~/repository.git")
git init
git remote add origin $REMOTE
git fetch
LATEST_TAG=$(git tag | grep pantheon_live_ | sort -k1.15n | tail -1)
git checkout $LATEST_TAG
git pull origin $LATEST_TAG
rm -rf vendor
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer Downloads
uses: actions/cache@v1
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 --no-interaction --no-progress install
- name: Create bin aliases
run: |
echo "$GITHUB_WORKSPACE/vendor/bin" >> $GITHUB_PATH
- name: Authenticate Terminus
run: |
terminus auth:login --machine-token $TERMINUS_MACHINE_TOKEN
- name: Set temporary connection credentials
run: |
CREDS=$(php private/scripts/cron/set_connection.php)
for CRED in ${CREDS};do
echo $CRED >> $GITHUB_ENV
done
- name: Run Drush command
run: drush status --full --show-passwords