-
Notifications
You must be signed in to change notification settings - Fork 41
86 lines (74 loc) · 2.85 KB
/
checkout-cd-prod-beta.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
name: Module checkout CD Production Beta
on:
push:
tags:
- '*'
env:
MODULE_NAME: ps_checkout
GCLOUD_TOKEN_PATH: ./token.json
jobs:
checkout_cd:
name: Module Checkout continuous deployment
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout the repository
uses: actions/checkout@v2
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GCLOUD_PROJECT_PRODUCTION }}
service_account_key: ${{ secrets.G_CREDENTIAL_PRODUCTION }}
export_default_credentials: true
- name: Copy env files
run: |
gcloud components install beta
gcloud beta secrets versions access latest --secret="checkout-module" > .env
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PRODUCTION }}
- name: Build module
run: |
composer install
cd _dev
yarn
- name: Delete old module
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST_PRODUCTION }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: sudo su -c 'docker exec $(docker ps -qf "name=${{ secrets.CONTAINER_NAME }}") rm -rf modules/${{ env.MODULE_NAME }}'
- name: Copy module
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST_PRODUCTION }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
source: "."
target: ${{ env.MODULE_NAME }}
- name: Move module
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST_PRODUCTION }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo su -c 'mv ${{ env.MODULE_NAME }} ${{ secrets.MODULE_PATH }}'
sudo su -c 'chown -R www-data:www-data ${{ secrets.MODULE_PATH }}/${{ env.MODULE_NAME }}'
- name: Install module
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST_PRODUCTION }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo su -c 'docker exec $(docker ps -qf "name=${{ secrets.CONTAINER_NAME }}") bin/console prestashop:module install ${{ env.MODULE_NAME }}'
- name: Clear cache
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST_PRODUCTION }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo su -c 'docker exec $(docker ps -qf "name=${{ secrets.CONTAINER_NAME }}") bin/console cache:cl'
sudo su -c 'docker exec $(docker ps -qf "name=${{ secrets.CONTAINER_NAME }}") chmod -R 777 var/cache var/logs'