-
Notifications
You must be signed in to change notification settings - Fork 3
137 lines (118 loc) · 3.96 KB
/
clone-post.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
name: Clone And QA Deploy WordPress Post
on:
workflow_dispatch:
inputs:
environment:
required: true
type: string
description: "The deployment environment (QA, PROD)"
default: "QA"
postID:
required: true
type: string
description: "The ID of the page to clone"
default: "25163"
jobs:
clone_post:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Run cloning script
run: python wordpress-cloning-script.py ${{ inputs.environment }} ${{ inputs.postID }} ${{ secrets.WORDPRESS_USERNAME }} ${{ secrets.WORDPRESS_PASSWORD }}
- name: Configure git user
run: |
git config user.name 'GitHub Actions'
git config user.email '[email protected]'
- name: Commit and push changes
run: |
git add .
# Check if there are any changes
if git diff --staged --quiet; then
echo "No changes to commit."
else
git commit -m "Cloned WordPress post ${{ github.event.inputs.postID }} for environment ${{ github.event.inputs.environment }}"
git push
fi
upload_to_s3:
needs: clone_post
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: build
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'
# clear_s3_bucket:
# needs: clone_post
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1
# - name: Empty S3 Bucket
# run: |
# aws s3 rm s3://orcid-qa-public-page --recursive
# upload_to_s3:
# needs: clear_s3_bucket
# 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: jakejarvis/s3-sync-action@master
# with:
# args: --follow-symlinks --delete
# env:
# AWS_S3_BUCKET: orcid-qa-public-page
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# AWS_REGION: 'us-east-1'
# SOURCE_DIR: 'dist'
# cloudfront_invalidation:
# needs: upload_to_s3
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1
# - name: Invalidate CloudFront cache
# run: |
# aws cloudfront create-invalidation --distribution-id E3AOMNP9201N9Z --paths "/*"