Skip to content

Commit 3ddffc0

Browse files
committed
ci: add GitHub Actions workflows for dev, staging, prod, and pull request environments [no ci]
1 parent 7d81a9c commit 3ddffc0

File tree

5 files changed

+320
-0
lines changed

5 files changed

+320
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Pull Requests
2+
3+
on:
4+
pull_request:
5+
branches: [dev]
6+
7+
jobs:
8+
build-test-static:
9+
name: Build and run static analysis
10+
permissions:
11+
id-token: write
12+
contents: read
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/setup-node@v2
16+
with:
17+
node-version: 20
18+
19+
- uses: actions/checkout@v2
20+
21+
# Install and cache dependencies.
22+
- uses: actions/cache@v4
23+
id: yarn-cache
24+
with:
25+
path: .yarn/cache
26+
key: yarn-${{ hashFiles('**/yarn.lock') }}
27+
28+
- name: Install dependencies
29+
run: yarn --immutable
30+
31+
# Run static code analysis.
32+
- name: Check code formatting
33+
run: yarn format
34+
35+
- name: ESLint
36+
run: yarn lint
37+
38+
deploy:
39+
name: Deploy to PR environment
40+
permissions:
41+
id-token: write
42+
contents: read
43+
pull-requests: write
44+
needs: build-test-static
45+
runs-on: ubuntu-latest
46+
# We use "dev" environment variables here, but, if needed, a separate set of
47+
# variables and a separate pull requests-related AWS account can be used too.
48+
env:
49+
NODE_OPTIONS: --max_old_space_size=4096
50+
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
51+
OPENSEARCH_DOMAIN_NAME: ${{ secrets.DEV_OPENSEARCH_DOMAIN_NAME }}
52+
OPENSEARCH_INDEX_PREFIX: pr${{ github.event.pull_request.number }}
53+
PULUMI_SECRETS_PROVIDER: ${{ secrets.DEV_PULUMI_SECRETS_PROVIDER }}
54+
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.DEV_PULUMI_CONFIG_PASSPHRASE }}
55+
WEBINY_PULUMI_BACKEND: ${{ secrets.DEV_WEBINY_PULUMI_BACKEND_PULL_REQUESTS }}
56+
WEBINY_PROJECT_ID: ${{ secrets.DEV_WEBINY_PROJECT_ID }}
57+
WEBINY_PROJECT_API_KEY: ${{ secrets.DEV_WEBINY_PROJECT_API_KEY }}
58+
steps:
59+
- name: Configure AWS Credentials
60+
uses: aws-actions/configure-aws-credentials@v4
61+
with:
62+
role-to-assume: ${{ secrets.DEV_AWS_ROLE_ARN }}
63+
aws-region: ${{ secrets.DEV_AWS_REGION }}
64+
65+
- uses: actions/setup-node@v2
66+
with:
67+
node-version: 20
68+
69+
- uses: actions/checkout@v2
70+
71+
# Install and cache dependencies.
72+
- uses: actions/cache@v4
73+
id: yarn-cache
74+
with:
75+
path: .yarn/cache
76+
key: yarn-${{ hashFiles('**/yarn.lock') }}
77+
78+
- name: Install dependencies
79+
run: yarn --immutable
80+
81+
# Deploy to a short-lived environment (will be destroyed once the PR is closed).
82+
- name: Deploy core
83+
run: yarn webiny deploy core --env pr${{ github.event.pull_request.number }}
84+
85+
- name: Deploy API
86+
run: yarn webiny deploy api --env pr${{ github.event.pull_request.number }}
87+
88+
- name: Deploy Admin
89+
run: yarn webiny deploy admin --env pr${{ github.event.pull_request.number }}
90+
91+
# Add additional steps if needed. For example, if you have additional E2E
92+
# tests done with Cypress (https://www.cypress.io/), you can run them here.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Pull Requests (Closed)
2+
3+
on:
4+
pull_request:
5+
branches: [dev]
6+
types: [closed]
7+
8+
jobs:
9+
destroy-project:
10+
name: Destroy project deployed into a short-lived environment
11+
permissions:
12+
id-token: write
13+
contents: read
14+
runs-on: ubuntu-latest
15+
env:
16+
# This first step ensures we don't run the workflow if the repository is empty.
17+
# Feel free to remove this step once your project is pushed to the repository.
18+
NODE_OPTIONS: --max_old_space_size=4096
19+
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
20+
OPENSEARCH_DOMAIN_NAME: ${{ secrets.DEV_OPENSEARCH_DOMAIN_NAME }}
21+
OPENSEARCH_INDEX_PREFIX: pr${{ github.event.pull_request.number }}
22+
PULUMI_SECRETS_PROVIDER: ${{ secrets.DEV_PULUMI_SECRETS_PROVIDER }}
23+
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.DEV_PULUMI_CONFIG_PASSPHRASE }}
24+
WEBINY_PULUMI_BACKEND: ${{ secrets.DEV_WEBINY_PULUMI_BACKEND_PULL_REQUESTS }}
25+
WEBINY_PROJECT_ID: ${{ secrets.DEV_WEBINY_PROJECT_ID }}
26+
WEBINY_PROJECT_API_KEY: ${{ secrets.DEV_WEBINY_PROJECT_API_KEY }}
27+
steps:
28+
- name: Configure AWS Credentials
29+
uses: aws-actions/configure-aws-credentials@v4
30+
with:
31+
role-to-assume: ${{ secrets.DEV_AWS_ROLE_ARN }}
32+
aws-region: ${{ secrets.DEV_AWS_REGION }}
33+
- uses: actions/setup-node@v2
34+
with:
35+
node-version: 20
36+
37+
- uses: actions/checkout@v2
38+
39+
# Install and cache dependencies.
40+
- uses: actions/cache@v4
41+
id: yarn-cache
42+
with:
43+
path: .yarn/cache
44+
key: yarn-${{ hashFiles('**/yarn.lock') }}
45+
46+
- name: Install dependencies
47+
run: yarn --immutable
48+
49+
# Destroy short-lived environment.
50+
- name: Destroy
51+
run: yarn webiny destroy --env pr${{ github.event.pull_request.number }} --confirm-destroy-env pr${{ github.event.pull_request.number }} --debug
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Dev Branch - Push
2+
3+
on:
4+
push:
5+
branches: [dev]
6+
7+
# Ensures only one deployment to "dev" environment can be in progress at the same time.
8+
concurrency: dev
9+
10+
jobs:
11+
build-test-deploy:
12+
name: Build and test
13+
runs-on: ubuntu-latest
14+
env:
15+
NODE_OPTIONS: --max_old_space_size=4096
16+
AWS_REGION: ${{ secrets.DEV_AWS_REGION }}
17+
PULUMI_SECRETS_PROVIDER: ${{ secrets.DEV_PULUMI_SECRETS_PROVIDER }}
18+
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.DEV_PULUMI_CONFIG_PASSPHRASE }}
19+
WEBINY_PULUMI_BACKEND: ${{ secrets.DEV_WEBINY_PULUMI_BACKEND }}
20+
WEBINY_PROJECT_ID: ${{ secrets.DEV_WEBINY_PROJECT_ID }}
21+
WEBINY_PROJECT_API_KEY: ${{ secrets.DEV_WEBINY_PROJECT_API_KEY }}
22+
permissions:
23+
id-token: write
24+
contents: read
25+
steps:
26+
- name: Configure AWS Credentials
27+
uses: aws-actions/configure-aws-credentials@v4
28+
with:
29+
role-to-assume: ${{ secrets.DEV_AWS_ROLE_ARN }}
30+
aws-region: ${{ secrets.DEV_AWS_REGION }}
31+
- uses: actions/setup-node@v2
32+
with:
33+
node-version: 20
34+
35+
- uses: actions/checkout@v4
36+
37+
# Install and cache dependencies.
38+
- uses: actions/cache@v4
39+
id: yarn-cache
40+
with:
41+
path: .yarn/cache
42+
key: yarn-${{ hashFiles('**/yarn.lock') }}
43+
44+
45+
- name: Install dependencies
46+
run: yarn --immutable
47+
48+
# Run static code analysis.
49+
- name: Check code formatting
50+
run: yarn format
51+
52+
- name: ESLint
53+
run: yarn lint
54+
55+
- name: Deploy
56+
run: yarn webiny deploy --env dev
57+
58+
# Add additional steps if needed. For example, if you have additional E2E
59+
# tests done with Cypress (https://www.cypress.io/), you can run them here.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Prod Branch - Push
2+
3+
on:
4+
push:
5+
branches: [prod]
6+
7+
# Ensures only one deployment to "prod" environment can be in progress at the same time.
8+
concurrency: prod
9+
10+
jobs:
11+
build-test-deploy:
12+
name: Build and test
13+
runs-on: ubuntu-latest
14+
env:
15+
NODE_OPTIONS: --max_old_space_size=4096
16+
AWS_REGION: ${{ secrets.PROD_AWS_REGION }}
17+
PULUMI_SECRETS_PROVIDER: ${{ secrets.PROD_PULUMI_SECRETS_PROVIDER }}
18+
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PROD_PULUMI_CONFIG_PASSPHRASE }}
19+
WEBINY_PULUMI_BACKEND: ${{ secrets.PROD_WEBINY_PULUMI_BACKEND }}
20+
WEBINY_PROJECT_ID: ${{ secrets.PROD_WEBINY_PROJECT_ID }}
21+
WEBINY_PROJECT_API_KEY: ${{ secrets.PROD_WEBINY_PROJECT_API_KEY }}
22+
permissions:
23+
id-token: write
24+
contents: read
25+
steps:
26+
- name: Configure AWS Credentials
27+
uses: aws-actions/configure-aws-credentials@v4
28+
with:
29+
role-to-assume: ${{ secrets.PROD_AWS_ROLE_ARN }}
30+
aws-region: ${{ secrets.PROD_AWS_REGION }}
31+
- uses: actions/setup-node@v2
32+
with:
33+
node-version: 20
34+
35+
- uses: actions/checkout@v4
36+
37+
# Install and cache dependencies.
38+
- uses: actions/cache@v4
39+
id: yarn-cache
40+
with:
41+
path: .yarn/cache
42+
key: yarn-${{ hashFiles('**/yarn.lock') }}
43+
44+
45+
- name: Install dependencies
46+
run: yarn --immutable
47+
48+
# Run static code analysis.
49+
- name: Check code formatting
50+
run: yarn format
51+
52+
- name: ESLint
53+
run: yarn lint
54+
55+
- name: Deploy
56+
run: yarn webiny deploy --env prod
57+
58+
# Add additional steps if needed. For example, if you have additional E2E
59+
# tests done with Cypress (https://www.cypress.io/), you can run them here.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Staging Branch - Push
2+
3+
on:
4+
push:
5+
branches: [staging]
6+
7+
# Ensures only one deployment to "staging" environment can be in progress at the same time.
8+
concurrency: staging
9+
10+
jobs:
11+
build-test-deploy:
12+
name: Build and test
13+
runs-on: ubuntu-latest
14+
env:
15+
NODE_OPTIONS: --max_old_space_size=4096
16+
AWS_REGION: ${{ secrets.STAGING_AWS_REGION }}
17+
PULUMI_SECRETS_PROVIDER: ${{ secrets.STAGING_PULUMI_SECRETS_PROVIDER }}
18+
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.STAGING_PULUMI_CONFIG_PASSPHRASE }}
19+
WEBINY_PULUMI_BACKEND: ${{ secrets.STAGING_WEBINY_PULUMI_BACKEND }}
20+
WEBINY_PROJECT_ID: ${{ secrets.STAGING_WEBINY_PROJECT_ID }}
21+
WEBINY_PROJECT_API_KEY: ${{ secrets.STAGING_WEBINY_PROJECT_API_KEY }}
22+
permissions:
23+
id-token: write
24+
contents: read
25+
steps:
26+
- name: Configure AWS Credentials
27+
uses: aws-actions/configure-aws-credentials@v4
28+
with:
29+
role-to-assume: ${{ secrets.STAGING_AWS_ROLE_ARN }}
30+
aws-region: ${{ secrets.STAGING_AWS_REGION }}
31+
- uses: actions/setup-node@v2
32+
with:
33+
node-version: 20
34+
35+
- uses: actions/checkout@v4
36+
37+
# Install and cache dependencies.
38+
- uses: actions/cache@v4
39+
id: yarn-cache
40+
with:
41+
path: .yarn/cache
42+
key: yarn-${{ hashFiles('**/yarn.lock') }}
43+
44+
45+
- name: Install dependencies
46+
run: yarn --immutable
47+
48+
# Run static code analysis.
49+
- name: Check code formatting
50+
run: yarn format
51+
52+
- name: ESLint
53+
run: yarn lint
54+
55+
- name: Deploy
56+
run: yarn webiny deploy --env staging
57+
58+
# Add additional steps if needed. For example, if you have additional E2E
59+
# tests done with Cypress (https://www.cypress.io/), you can run them here.

0 commit comments

Comments
 (0)