-
Notifications
You must be signed in to change notification settings - Fork 3
151 lines (133 loc) · 4.56 KB
/
qa-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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Homepage QA Deploy
run-name: QA deploy WordPress ${{ inputs.environment }} - page ${{ inputs.postID }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
environment:
required: true
description: "WordPress environment"
type: choice
options:
- STAGING
- PROD
postID:
required: true
type: string
description: "The ID of the page to clone"
default: "25163"
jobs:
clone-post:
runs-on: ubuntu-latest
outputs:
script-success: ${{ steps.wordpress-cloning-main.outputs.script-success }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install node dependencies
run: npm install
- name: Run clone and process script
id: wordpress-cloning-main
run: |
python wordpress-cloning-main.py ${{ inputs.environment }} ${{ inputs.postID }} ${{ secrets.WORDPRESS_USERNAME }} ${{ secrets.WORDPRESS_PASSWORD }}
continue-on-error: true
env:
GITHUB_OUTPUT: ${{ github.output }}
GITHUB_STEP_SUMMARY: ${{ github.step_summary }}
- name: Check script success
if: steps.wordpress-cloning-main.outputs.script-success == 'false'
run: |
echo "Script failed, raising an error."
exit 1
- name: Upload WordPress Staging HTML to S3
uses: reggionick/s3-deploy@v4
if: ${{ inputs.environment != 'PROD' }}
with:
folder: dist
bucket: orcid-qa-public-page
bucket-region: 'us-east-1'
dist-id: 'E3AOMNP9201N9Z'
invalidation: /
delete-removed: true
no-cache: true
private: true
files-to-include: '{.*/**,**}'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
release_prod_wordpress_new_version:
runs-on: ubuntu-latest
needs: clone-post
if: inputs.environment == 'PROD' && needs.clone-post.outputs.script-success == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Get the current version tag
id: get_version
run: |
git checkout main
git pull
TAG=$(git tag --sort=-version:refname | head -n 1)
echo "Current version tag:" $TAG
echo "version=${TAG}" >> "$GITHUB_OUTPUT"
- name: Calculate new version
id: new_version
run: |
CURRENT_VERSION=${{ steps.get_version.outputs.version }}
MAJOR=$(echo $CURRENT_VERSION | cut -d'.' -f1)
MINOR=$(echo $CURRENT_VERSION | cut -d'.' -f2)
PATCH=$(echo $CURRENT_VERSION | cut -d'.' -f3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "New version: $NEW_VERSION"
echo "::set-output name=new_version::$NEW_VERSION"
- name: Create and push tag
run: |
NEW_TAG=${{ steps.new_version.outputs.new_version }}
git tag $NEW_TAG
git push origin $NEW_TAG
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.new_version.outputs.new_version }}
release_name: Release ${{ steps.new_version.outputs.new_version }}
draft: false
prerelease: false
upload_prod_wordpress_to_qa_s3:
needs: release_prod_wordpress_new_version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get recent changes
run: |
git pull
- name: Upload HTML to S3
uses: reggionick/s3-deploy@v4
with:
folder: dist
bucket: ${{secrets.QA_AWS_BUCKET}}
bucket-region: ${{ secrets.AWS_REGION }}
dist-id: ${{secrets.QA_CLOUDFRONT_DIST_ID}}
invalidation: /
delete-removed: true
no-cache: true
private: true
files-to-include: '{.*/**,**}'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'