-
Notifications
You must be signed in to change notification settings - Fork 114
132 lines (132 loc) Β· 5.92 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: deploy
on:
push:
branches:
- master
- stage
paths:
- '**.js'
- 'src/**'
- 'images/**'
jobs:
deploy:
if: (github.repository == 'Adventech/sabbath-school-lessons')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
- name: Get changed files and write the outputs to a JSON file
id: changed-files-write-output-files-json
uses: tj-actions/changed-files@v39
with:
json: true
write_output_files: true
- name: Verify the contents of the .github/outputs/all_changed_files.json file
run: |
cat .github/outputs/all_changed_files.json
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- run: gpg --quiet --batch --yes --decrypt --passphrase="$CREDS_PASSPHRASE" --output deploy-creds.tar deploy-creds.tar.gpg
env:
CREDS_PASSPHRASE: ${{ secrets.CREDS_PASSPHRASE }}
- run: tar xvf deploy-creds.tar
- uses: actions/setup-node@v2
with:
node-version: '16'
check-latest: true
- name: Add token for private packages
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGES_SECRET }}" >> .npmrc
- run: npm install
- run: npm install @Adventech/bible-tools
- run: node deploy -b ${{ steps.extract_branch.outputs.branch }}
- name: Web deploy
run: aws s3 cp dist/ s3://sabbath-school`[[ "${{ steps.extract_branch.outputs.branch }}" = "stage" ]] && echo '-stage'`.adventech.io --acl "public-read" --region us-east-1 --no-progress --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
deploy_v2:
if: (github.repository == 'Adventech/sabbath-school-lessons')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
- name: Get changed files and write the outputs to a JSON file
id: changed-files-write-output-files-json
uses: tj-actions/changed-files@v39
with:
json: true
write_output_files: true
- name: Verify the contents of the .github/outputs/all_changed_files.json file
run: |
cat .github/outputs/all_changed_files.json
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- run: gpg --quiet --batch --yes --decrypt --passphrase="$CREDS_PASSPHRASE" --output deploy-creds.tar deploy-creds.tar.gpg
env:
CREDS_PASSPHRASE: ${{ secrets.CREDS_PASSPHRASE }}
- run: tar xvf deploy-creds.tar
- uses: actions/setup-node@v2
with:
node-version: '16'
check-latest: true
- name: Add token for private packages
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGES_SECRET }}" >> .npmrc
- run: npm install
- run: npm install @Adventech/bible-tools
- run: node deploy -b ${{ steps.extract_branch.outputs.branch }} -v 2
- name: Web deploy
run: aws s3 cp dist/ s3://sabbath-school`[[ "${{ steps.extract_branch.outputs.branch }}" = "stage" ]] && echo '-stage'`.adventech.io --acl "public-read" --region us-east-1 --no-progress --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Running porting to API v3 script
run: node port-to-v3.js
if: github.ref == 'refs/heads/stage'
- name: Upload ported assets
if: github.ref == 'refs/heads/stage' && hashFiles('dist/port/assets') != ''
run: aws s3 cp dist/port/assets s3://sabbath-school-resources-assets.adventech.io/assets/ --acl "public-read" --region us-east-1 --no-progress --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Install ImageMagick
if: github.ref == 'refs/heads/stage' && hashFiles('dist/port/ss') != ''
run: sudo apt-get update && sudo apt-get install -y imagemagick pngquant
- name: Generate square and landscape cover versions
if: github.ref == 'refs/heads/stage' && hashFiles('dist/port/ss') != ''
run: ./runners/overlay/overlay-find.sh
- name: Upload ported content
if: github.ref == 'refs/heads/stage' && hashFiles('dist/port/ss') != ''
run: aws s3 cp dist/port/ss s3://sabbath-school-media-tmp/port/ss-`echo '${{ github.run_id }}'` --acl "public-read" --region us-east-1 --no-progress --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Trigger workflow in sabbath-school-resources
if: github.ref == 'refs/heads/stage' && hashFiles('dist/port/ss') != ''
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.PACKAGES_SECRET }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/Adventech/sabbath-school-resources/dispatches \
-d '{"event_type": "trigger-workflow", "client_payload": { "port_id": "${{ github.run_id }}" }}'