-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from shanedg/stage/dev-pipeline
stage/dev-pipeline
- Loading branch information
Showing
11 changed files
with
352 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
name: GitHub Actions CI (Branch) | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
push: | ||
branches-ignore: | ||
- main | ||
- 'stage/**' | ||
workflow_call: | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: staging | ||
url: https://www-stage.trshcmpctr.com | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: node common/scripts/install-run-rush.js install | ||
- uses: docker://node:18.16.1 | ||
- run: node common/scripts/install-run-rush.js build | ||
- run: (cd discord && ./client_config_ci.sh) | ||
env: | ||
DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} | ||
DISCORD_CLIENT_SECRET: ${{ secrets.DISCORD_CLIENT_SECRET }} | ||
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }} | ||
DISCORD_SESSION_SECRET: ${{ secrets.DISCORD_SESSION_SECRET }} | ||
DISCORD_REDIRECT_URI: ${{ secrets.DISCORD_REDIRECT_URI }} | ||
- run: (cd deploy && ./client_config_ci.sh) | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
ENVIRONMENT: ${{ vars.ENVIRONMENT }} | ||
- run: node common/scripts/install-run-rush.js lint | ||
- run: node common/scripts/install-run-rush.js lint:md | ||
- run: node common/scripts/install-run-rush.js test | ||
- run: node common/scripts/install-run-rush.js test:cypress --verbose | ||
- run: node common/scripts/install-run-rush.js deploy --create-archive deploy.zip | ||
- run: (cd deploy && npm run upload ${{ vars.ENVIRONMENT }}) | ||
- run: (cd deploy && npm start ${{ vars.ENVIRONMENT }}) | ||
install: | ||
uses: ./.github/workflows/install.yml | ||
|
||
build: | ||
needs: | ||
- install | ||
uses: ./.github/workflows/build.yml | ||
|
||
lint: | ||
needs: | ||
- install | ||
- build | ||
uses: ./.github/workflows/lint.yml | ||
|
||
unit-test: | ||
needs: | ||
- install | ||
- build | ||
uses: ./.github/workflows/unit-test.yml | ||
|
||
e2e-test: | ||
needs: | ||
- install | ||
- build | ||
uses: ./.github/workflows/e2e-test.yml | ||
# Need repository-level secrets | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Build | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Restore Build Cache | ||
id: restore-build-cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
*/dist | ||
key: ${{ runner.os }}-build-${{ hashFiles('common/config/rush/repo-state.json') }} | ||
# Only need a cache hit or miss, | ||
# cached dependencies aren't used until following jobs | ||
lookup-only: true | ||
|
||
- name: Restore Dependencies From Cache | ||
id: restore-cache | ||
uses: actions/cache/restore@v4 | ||
if: steps.restore-build-cache.outputs.cache-hit != 'true' | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/repo-state.json') }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Build | ||
if: steps.restore-build-cache.outputs.cache-hit != 'true' | ||
run: node common/scripts/install-run-rush.js build | ||
|
||
- name: Save Build Cache | ||
id: save-cache | ||
uses: actions/cache/save@v4 | ||
if: steps.restore-build-cache.outputs.cache-hit != 'true' | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
*/dist | ||
key: ${{ steps.restore-build-cache.outputs.cache-primary-key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Deploy | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
url: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-22.04 | ||
environment: | ||
name: ${{ inputs.environment }} | ||
url: ${{ inputs.url }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Restore Build Cache | ||
id: restore-build-cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
*/dist | ||
key: ${{ runner.os }}-build-${{ hashFiles('common/config/rush/repo-state.json') }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Configure Discord Secrets | ||
run: (cd discord && ./client_config_ci.sh) | ||
env: | ||
# Repository-level secrets | ||
DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} | ||
DISCORD_CLIENT_SECRET: ${{ secrets.DISCORD_CLIENT_SECRET }} | ||
DISCORD_SESSION_SECRET: ${{ secrets.DISCORD_SESSION_SECRET }} | ||
# Secrets overridden by the workflow environment | ||
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }} | ||
DISCORD_REDIRECT_URI: ${{ secrets.DISCORD_REDIRECT_URI }} | ||
|
||
- name: Configure Deploy Secrets | ||
run: (cd deploy && ./client_config_ci.sh) | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
ENVIRONMENT: ${{ inputs.environment }} | ||
|
||
- name: Create Deployment Artifacts | ||
run: node common/scripts/install-run-rush.js deploy --create-archive deploy.zip | ||
|
||
- name: Upload Deployment Artifacts | ||
# Artifacts are uploaded via aws s3 but could also be done with https://github.com/actions/upload-artifact | ||
# Downloading artifacts to new instances is already convenient via aws credentials and cli | ||
run: (cd deploy && npm run upload ${{ inputs.environment }}) | ||
|
||
- name: Deploy | ||
run: (cd deploy && npm start ${{ inputs.environment }}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: E2E Tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
e2e-test: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Restore Build Cache | ||
id: restore-build-cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
*/dist | ||
key: ${{ runner.os }}-build-${{ hashFiles('common/config/rush/repo-state.json') }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Configure Discord Secrets | ||
run: (cd discord && ./client_config_ci.sh) | ||
env: | ||
# Repository-level secrets | ||
DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} | ||
DISCORD_CLIENT_SECRET: ${{ secrets.DISCORD_CLIENT_SECRET }} | ||
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }} | ||
DISCORD_REDIRECT_URI: ${{ secrets.DISCORD_REDIRECT_URI }} | ||
DISCORD_SESSION_SECRET: ${{ secrets.DISCORD_SESSION_SECRET }} | ||
|
||
- name: E2E Tests | ||
run: node common/scripts/install-run-rush.js test:cypress --verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Install | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Restore Cache | ||
id: restore-cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/repo-state.json') }} | ||
# Only need a cache hit or miss, | ||
# cached dependencies aren't used until following jobs | ||
lookup-only: true | ||
|
||
- name: Install | ||
if: steps.restore-cache.outputs.cache-hit != 'true' | ||
run: node common/scripts/install-run-rush.js install | ||
|
||
- name: Save Cache | ||
id: save-cache | ||
uses: actions/cache/save@v4 | ||
if: steps.restore-cache.outputs.cache-hit != 'true' | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
key: ${{ steps.restore-cache.outputs.cache-primary-key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Lint | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Restore Build Cache | ||
id: restore-build-cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.cache/Cypress | ||
common/temp | ||
*/.rush/temp | ||
*/node_modules | ||
*/dist | ||
key: ${{ runner.os }}-build-${{ hashFiles('common/config/rush/repo-state.json') }} | ||
fail-on-cache-miss: true | ||
|
||
- name: Configure Discord Secrets | ||
run: (cd discord && ./client_config_ci.sh) | ||
env: | ||
# Any values will do, discord application does not run during this job | ||
DISCORD_CLIENT_ID: fake_discord_client_id | ||
DISCORD_CLIENT_SECRET: fake_discord_client_secret | ||
DISCORD_GUILD_ID: fake_guild_id | ||
DISCORD_SESSION_SECRET: fake_discord_session_secret | ||
DISCORD_REDIRECT_URI: fake_discord_redirect_uri | ||
|
||
- name: Configure Deploy Secrets | ||
run: (cd deploy && ./client_config_ci.sh) | ||
env: | ||
# Any values will do, deploy application does not run during this job | ||
AWS_ACCESS_KEY_ID: fake_aws_access_key_id | ||
AWS_SECRET_ACCESS_KEY: fake_aws_secret_access_key | ||
ENVIRONMENT: fake_environment | ||
|
||
- name: Lint JavaScript | ||
run: node common/scripts/install-run-rush.js lint | ||
|
||
- name: Lint Markdown | ||
run: node common/scripts/install-run-rush.js lint:md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,23 @@ | ||
name: GitHub Actions CI (Main) | ||
|
||
# Run only one deploy to production at a time | ||
concurrency: production-deploy-gate | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: production | ||
main-branch: | ||
uses: ./.github/workflows/branch.yml | ||
secrets: inherit | ||
|
||
main-deploy: | ||
needs: | ||
- main-branch | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: production | ||
url: https://www.trshcmpctr.com | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: node common/scripts/install-run-rush.js install | ||
- uses: docker://node:18.16.1 | ||
- run: node common/scripts/install-run-rush.js build | ||
- run: (cd discord && ./client_config_ci.sh) | ||
env: | ||
DISCORD_CLIENT_ID: ${{ secrets.DISCORD_CLIENT_ID }} | ||
DISCORD_CLIENT_SECRET: ${{ secrets.DISCORD_CLIENT_SECRET }} | ||
DISCORD_GUILD_ID: ${{ secrets.DISCORD_GUILD_ID }} | ||
DISCORD_SESSION_SECRET: ${{ secrets.DISCORD_SESSION_SECRET }} | ||
DISCORD_REDIRECT_URI: ${{ secrets.DISCORD_REDIRECT_URI }} | ||
- run: (cd deploy && ./client_config_ci.sh) | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
ENVIRONMENT: ${{ vars.ENVIRONMENT }} | ||
- run: node common/scripts/install-run-rush.js lint | ||
- run: node common/scripts/install-run-rush.js lint:md | ||
- run: node common/scripts/install-run-rush.js test | ||
- run: node common/scripts/install-run-rush.js test:cypress --verbose | ||
- run: node common/scripts/install-run-rush.js deploy --create-archive deploy.zip | ||
- run: (cd deploy && npm run upload ${{ vars.ENVIRONMENT }}) | ||
- run: (cd deploy && npm start ${{ vars.ENVIRONMENT }}) | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: GitHub Actions CI (Staging Deploy) | ||
|
||
# Run only one deploy to staging at a time | ||
concurrency: staging-deploy-gate | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'stage/**' | ||
|
||
jobs: | ||
stage-branch: | ||
uses: ./.github/workflows/branch.yml | ||
secrets: inherit | ||
|
||
stage-deploy: | ||
needs: | ||
- stage-branch | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
environment: staging | ||
url: https://www-stage.trshcmpctr.com | ||
secrets: inherit |
Oops, something went wrong.