generated from freeCodeCamp/template
-
-
Notifications
You must be signed in to change notification settings - Fork 39
149 lines (117 loc) · 5.93 KB
/
deploy-eng.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
name: Eng - Build and Deploy
on:
workflow_dispatch:
schedule:
# Here are the times for the cron:
#
# Sun, Mon, Tue, Thu, Fri : at 00:00, 03:00, 06:00, 09:00, 12:00, 15:00, 18:00 UTC
# Wed, Sat : at --:--, --:--, 06:00, 09:00, 12:00, 15:00, 18:00 UTC
#
# There is a 6 hour maintenance window on Wednesdays and Saturdays,
# and the crons are scheduled at 5 mins past the hour.
#
- cron: '5 0,3,6,9,12,15,18 * * 0-2,4-5'
- cron: '5 6,9,12,15,18 * * 3,6'
jobs:
build:
name: Build
runs-on: [self-hosted, on-aws]
strategy:
fail-fast: false
matrix:
node-version: [18.x]
languages: [english]
site_tlds: [org]
env:
BUILD_LANG: ${{ matrix.languages }}
ALGOLIA_API_KEY: ${{ secrets.ALGOLIA_API_KEY }}
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
CHINESE_GHOST_API_URL: ${{ secrets.CHINESE_GHOST_API_URL }}
CHINESE_GHOST_API_VERSION: ${{ secrets.CHINESE_GHOST_API_VERSION }}
CHINESE_GHOST_CONTENT_API_KEY: ${{ secrets.CHINESE_GHOST_CONTENT_API_KEY }}
ENGLISH_GHOST_API_URL: ${{ secrets.ENGLISH_GHOST_API_URL }}
ENGLISH_GHOST_API_VERSION: ${{ secrets.ENGLISH_GHOST_API_VERSION }}
ENGLISH_GHOST_CONTENT_API_KEY: ${{ secrets.ENGLISH_GHOST_CONTENT_API_KEY }}
ESPANOL_GHOST_API_URL: ${{ secrets.ESPANOL_GHOST_API_URL }}
ESPANOL_GHOST_API_VERSION: ${{ secrets.ESPANOL_GHOST_API_VERSION }}
ESPANOL_GHOST_CONTENT_API_KEY: ${{ secrets.ESPANOL_GHOST_CONTENT_API_KEY }}
FRENCH_GHOST_API_URL: ${{ secrets.FRENCH_GHOST_API_URL }}
FRENCH_GHOST_API_VERSION: ${{ secrets.FRENCH_GHOST_API_VERSION }}
FRENCH_GHOST_CONTENT_API_KEY: ${{ secrets.FRENCH_GHOST_CONTENT_API_KEY }}
ITALIAN_GHOST_API_URL: ${{ secrets.ITALIAN_GHOST_API_URL }}
ITALIAN_GHOST_API_VERSION: ${{ secrets.ITALIAN_GHOST_API_VERSION }}
ITALIAN_GHOST_CONTENT_API_KEY: ${{ secrets.ITALIAN_GHOST_CONTENT_API_KEY }}
JAPANESE_GHOST_API_URL: ${{ secrets.JAPANESE_GHOST_API_URL }}
JAPANESE_GHOST_API_VERSION: ${{ secrets.JAPANESE_GHOST_API_VERSION }}
JAPANESE_GHOST_CONTENT_API_KEY: ${{ secrets.JAPANESE_GHOST_CONTENT_API_KEY }}
KOREAN_GHOST_API_URL: ${{ secrets.KOREAN_GHOST_API_URL }}
KOREAN_GHOST_API_VERSION: ${{ secrets.KOREAN_GHOST_API_VERSION }}
KOREAN_GHOST_CONTENT_API_KEY: ${{ secrets.KOREAN_GHOST_CONTENT_API_KEY }}
PORTUGUESE_GHOST_API_URL: ${{ secrets.PORTUGUESE_GHOST_API_URL }}
PORTUGUESE_GHOST_API_VERSION: ${{ secrets.PORTUGUESE_GHOST_API_VERSION }}
PORTUGUESE_GHOST_CONTENT_API_KEY: ${{ secrets.PORTUGUESE_GHOST_CONTENT_API_KEY }}
UKRAINIAN_GHOST_API_URL: ${{ secrets.UKRAINIAN_GHOST_API_URL }}
UKRAINIAN_GHOST_API_VERSION: ${{ secrets.UKRAINIAN_GHOST_API_VERSION }}
UKRAINIAN_GHOST_CONTENT_API_KEY: ${{ secrets.UKRAINIAN_GHOST_CONTENT_API_KEY }}
URDU_GHOST_API_URL: ${{ secrets.URDU_GHOST_API_URL }}
URDU_GHOST_API_VERSION: ${{ secrets.URDU_GHOST_API_VERSION }}
URDU_GHOST_CONTENT_API_KEY: ${{ secrets.URDU_GHOST_CONTENT_API_KEY }}
ADS_ENABLED: ${{ secrets.ADS_ENABLED }}
GOOGLE_ADSENSE_DATA_AD_CLIENT: ${{ secrets.GOOGLE_ADSENSE_DATA_AD_CLIENT }}
GOOGLE_ADSENSE_DATA_AD_SLOT: ${{ secrets.GOOGLE_ADSENSE_DATA_AD_SLOT }}
POSTS_PER_PAGE: ${{ secrets.POSTS_PER_PAGE }}
SITE_DOMAIN: freecodecamp.${{ matrix.site_tlds }}
LOCALE_FOR_UI: ${{ matrix.languages }}
LOCALE_FOR_GHOST: ${{ matrix.languages }}
steps:
- name: Checkout source code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm ci
sudo apt-get install make
- name: Build site
run: npm run build
env:
NODE_ENV: production
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # tag=v2
- name: Create a tagname
id: tagname
run: |
echo "tagname=$(git rev-parse --short HEAD)-$(date +%Y%m%d)-$(date +%H%M)" >> $GITHUB_ENV
- name: Build & Tag Images
run: |
docker build . \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/news-${{ matrix.languages }}:$tagname \
--tag registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/news-${{ matrix.languages }}:latest \
--build-arg BUILD_LANGUAGE=${{ matrix.languages }} \
--file docker/Dockerfile
# - name: Build the registry test image
# run: |
# cd registry-test
# REGISTRY_NAME=${{ secrets.DOCR_NAME }} TAGNAME_CI=$tagname make build
# cd ..
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 1200
- name: Push image to DigitalOcean Container Registry
run: |
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/news-${{ matrix.languages }}:$tagname
docker push registry.digitalocean.com/${{ secrets.DOCR_NAME }}/${{ matrix.site_tlds }}/news-${{ matrix.languages }}:latest
# - name: Push the registry test image
# run: |
# cd registry-test
# REGISTRY_NAME=${{ secrets.DOCR_NAME }} TAGNAME_CI=$tagname make push
# cd ..
- name: Clean up Self-hosted setup
uses: colpal/actions-clean@36e6ca1abd35efe61cb60f912bd7837f67887c8a # tag=v1
if: ${{ always() }} # To ensure this step runs even when earlier steps fail
# Deployments are automated via https://github.com/freeCodeCamp/news-config