mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-15 17:19:10 +00:00
chore: update prettier tab width for consistency (#175)
This commit is contained in:
parent
a931f8c69c
commit
f24d2fcc99
247 changed files with 7224 additions and 7375 deletions
32
.github/dependabot.yml
vendored
32
.github/dependabot.yml
vendored
|
@ -1,21 +1,21 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: 'npm'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
- package-ecosystem: 'npm'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
|
||||
- package-ecosystem: 'gomod'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
- package-ecosystem: 'gomod'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
|
||||
- package-ecosystem: 'terraform'
|
||||
directory: '/terraform'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
- package-ecosystem: 'terraform'
|
||||
directory: '/terraform'
|
||||
schedule:
|
||||
interval: 'daily'
|
||||
|
|
354
.github/workflows/build.yml
vendored
354
.github/workflows/build.yml
vendored
|
@ -3,211 +3,211 @@ name: Roleypoly CI
|
|||
on: push
|
||||
|
||||
jobs:
|
||||
go_test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Go CI
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/cache@v2.1.4
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.15.5'
|
||||
go_test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Go CI
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- uses: actions/cache@v2.1.4
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.15.5'
|
||||
|
||||
- run: go vet ./...
|
||||
- run: go vet ./...
|
||||
|
||||
- run: go test ./...
|
||||
- run: go test ./...
|
||||
|
||||
node_test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node CI
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
node_test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Node CI
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- uses: actions/setup-node@v2.1.5
|
||||
with:
|
||||
node-version: '14'
|
||||
- uses: actions/setup-node@v2.1.5
|
||||
with:
|
||||
node-version: '14'
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- uses: actions/cache@v2.1.4
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- uses: actions/cache@v2.1.4
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn install --frozen-lockfile
|
||||
|
||||
- run: yarn lint
|
||||
- run: yarn lint
|
||||
|
||||
- run: yarn test
|
||||
- run: yarn test
|
||||
|
||||
worker_build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Worker Build & Publish
|
||||
needs:
|
||||
- node_test
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
worker_build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Worker Build & Publish
|
||||
needs:
|
||||
- node_test
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- uses: actions/setup-node@v2.1.5
|
||||
with:
|
||||
node-version: '14'
|
||||
- uses: actions/setup-node@v2.1.5
|
||||
with:
|
||||
node-version: '14'
|
||||
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@master
|
||||
with:
|
||||
project_id: ${{ secrets.GCS_PROJECT_ID }}
|
||||
service_account_key: ${{ secrets.GCS_TF_KEY }}
|
||||
export_default_credentials: true
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@master
|
||||
with:
|
||||
project_id: ${{ secrets.GCS_PROJECT_ID }}
|
||||
service_account_key: ${{ secrets.GCS_TF_KEY }}
|
||||
export_default_credentials: true
|
||||
|
||||
- name: Check if already deployed
|
||||
id: check
|
||||
run: |
|
||||
gsutil stat gs://roleypoly-artifacts/backend-worker/${{ github.sha }}/script.js \
|
||||
&& echo ::set-output name=skip::1 \
|
||||
|| echo ::set-output name=skip::0
|
||||
- name: Check if already deployed
|
||||
id: check
|
||||
run: |
|
||||
gsutil stat gs://roleypoly-artifacts/backend-worker/${{ github.sha }}/script.js \
|
||||
&& echo ::set-output name=skip::1 \
|
||||
|| echo ::set-output name=skip::0
|
||||
|
||||
- run: npm i -g @cloudflare/wrangler
|
||||
if: steps.check.outputs.skip == '0'
|
||||
- run: npm i -g @cloudflare/wrangler
|
||||
if: steps.check.outputs.skip == '0'
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
if: steps.check.outputs.skip == '0'
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
- name: Get yarn cache directory path
|
||||
if: steps.check.outputs.skip == '0'
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- uses: actions/cache@v2.1.4
|
||||
if: steps.check.outputs.skip == '0'
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
- uses: actions/cache@v2.1.4
|
||||
if: steps.check.outputs.skip == '0'
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- run: yarn install --frozen-lockfile
|
||||
if: steps.check.outputs.skip == '0'
|
||||
- run: yarn install --frozen-lockfile
|
||||
if: steps.check.outputs.skip == '0'
|
||||
|
||||
- run: |
|
||||
wrangler init
|
||||
echo 'webpack_config = "packages/api/webpack.config.js"' | tee -a wrangler.toml
|
||||
wrangler build
|
||||
if: steps.check.outputs.skip == '0'
|
||||
- run: |
|
||||
wrangler init
|
||||
echo 'webpack_config = "packages/api/webpack.config.js"' | tee -a wrangler.toml
|
||||
wrangler build
|
||||
if: steps.check.outputs.skip == '0'
|
||||
|
||||
- id: upload-file
|
||||
if: steps.check.outputs.skip == '0'
|
||||
uses: google-github-actions/upload-cloud-storage@main
|
||||
with:
|
||||
path: worker/script.js
|
||||
destination: roleypoly-artifacts/backend-worker/${{ github.sha }}
|
||||
credentials: ${{ secrets.GCS_TF_KEY }}
|
||||
- id: upload-file
|
||||
if: steps.check.outputs.skip == '0'
|
||||
uses: google-github-actions/upload-cloud-storage@main
|
||||
with:
|
||||
path: worker/script.js
|
||||
destination: roleypoly-artifacts/backend-worker/${{ github.sha }}
|
||||
credentials: ${{ secrets.GCS_TF_KEY }}
|
||||
|
||||
docker_build:
|
||||
name: Docker Build & Publish
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- go_test
|
||||
- node_test
|
||||
strategy:
|
||||
matrix:
|
||||
dockerfile:
|
||||
- bot
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
docker_build:
|
||||
name: Docker Build & Publish
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- go_test
|
||||
- node_test
|
||||
strategy:
|
||||
matrix:
|
||||
dockerfile:
|
||||
- bot
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- uses: actions/cache@v2.1.4
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
- uses: actions/cache@v2.1.4
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/roleypoly/${{matrix.dockerfile}}
|
||||
tag-sha: true
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/roleypoly/${{matrix.dockerfile}}
|
||||
tag-sha: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: roleypoly
|
||||
password: ${{ secrets.GHCR_PAT }}
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: roleypoly
|
||||
password: ${{ secrets.GHCR_PAT }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
id: docker
|
||||
with:
|
||||
context: .
|
||||
file: ./hack/dockerfiles/${{matrix.dockerfile}}.Dockerfile
|
||||
push: true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
id: docker
|
||||
with:
|
||||
context: .
|
||||
file: ./hack/dockerfiles/${{matrix.dockerfile}}.Dockerfile
|
||||
push: true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
|
||||
- name: Pre-deploy - Save digest.txt
|
||||
run: |
|
||||
echo "${{ steps.docker.outputs.digest }}" > digest.txt
|
||||
- name: Pre-deploy - Save digest.txt
|
||||
run: |
|
||||
echo "${{ steps.docker.outputs.digest }}" > digest.txt
|
||||
|
||||
- name: Pre-deploy - Make digest artifact
|
||||
uses: actions/upload-artifact@v2.2.2
|
||||
with:
|
||||
name: ${{ matrix.dockerfile }}-digest
|
||||
path: digest.txt
|
||||
- name: Pre-deploy - Make digest artifact
|
||||
uses: actions/upload-artifact@v2.2.2
|
||||
with:
|
||||
name: ${{ matrix.dockerfile }}-digest
|
||||
path: digest.txt
|
||||
|
||||
trigger_deploy:
|
||||
name: Deploy to Stage
|
||||
needs:
|
||||
- docker_build
|
||||
- worker_build
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get Bot digest
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bot-digest
|
||||
path: .digests/bot
|
||||
trigger_deploy:
|
||||
name: Deploy to Stage
|
||||
needs:
|
||||
- docker_build
|
||||
- worker_build
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get Bot digest
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: bot-digest
|
||||
path: .digests/bot
|
||||
|
||||
- name: Set digests as addressable
|
||||
id: digests
|
||||
env:
|
||||
IMAGES: bot
|
||||
run: |
|
||||
set_digest_output() {
|
||||
echo ::set-output name=$1::@$(cat .digests/$1/digest.txt)
|
||||
}
|
||||
- name: Set digests as addressable
|
||||
id: digests
|
||||
env:
|
||||
IMAGES: bot
|
||||
run: |
|
||||
set_digest_output() {
|
||||
echo ::set-output name=$1::@$(cat .digests/$1/digest.txt)
|
||||
}
|
||||
|
||||
for image in $IMAGES; do
|
||||
set_digest_output $image
|
||||
done
|
||||
for image in $IMAGES; do
|
||||
set_digest_output $image
|
||||
done
|
||||
|
||||
- name: Invoke Deploy workflow
|
||||
uses: benc-uk/workflow-dispatch@v1
|
||||
with:
|
||||
workflow: Deploy
|
||||
token: ${{ secrets.GITOPS_TOKEN }}
|
||||
inputs: |-
|
||||
{
|
||||
"environment": "stage",
|
||||
"worker_tag": "${{ github.sha }}",
|
||||
"bot_tag": "${{ steps.digests.output.bot }}"
|
||||
}
|
||||
- name: Invoke Deploy workflow
|
||||
uses: benc-uk/workflow-dispatch@v1
|
||||
with:
|
||||
workflow: Deploy
|
||||
token: ${{ secrets.GITOPS_TOKEN }}
|
||||
inputs: |-
|
||||
{
|
||||
"environment": "stage",
|
||||
"worker_tag": "${{ github.sha }}",
|
||||
"bot_tag": "${{ steps.digests.output.bot }}"
|
||||
}
|
||||
|
|
78
.github/workflows/codeql-analysis.yml
vendored
78
.github/workflows/codeql-analysis.yml
vendored
|
@ -1,51 +1,51 @@
|
|||
name: 'Code Scanning - Action'
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
# ┌───────────── minute (0 - 59)
|
||||
# │ ┌───────────── hour (0 - 23)
|
||||
# │ │ ┌───────────── day of the month (1 - 31)
|
||||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
|
||||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# * * * * *
|
||||
- cron: '30 1 * * 0'
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
# ┌───────────── minute (0 - 59)
|
||||
# │ ┌───────────── hour (0 - 23)
|
||||
# │ │ ┌───────────── day of the month (1 - 31)
|
||||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
|
||||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# * * * * *
|
||||
- cron: '30 1 * * 0'
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
CodeQL-Build:
|
||||
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below).
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below).
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following
|
||||
# three lines and modify them (or add more) to build your code if your
|
||||
# project uses a compiled language
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following
|
||||
# three lines and modify them (or add more) to build your code if your
|
||||
# project uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
|
218
.github/workflows/deploy.yml
vendored
218
.github/workflows/deploy.yml
vendored
|
@ -1,128 +1,128 @@
|
|||
name: Deploy
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: 'One of: stage, prod'
|
||||
required: true
|
||||
default: stage
|
||||
bot_tag:
|
||||
description: 'tag/digest reference to a UI container build'
|
||||
required: false
|
||||
default: ':main'
|
||||
worker_tag:
|
||||
description: 'bucket key to fetch worker from'
|
||||
required: false
|
||||
default: '' # Empty will try using current main branch hash
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
description: 'One of: stage, prod'
|
||||
required: true
|
||||
default: stage
|
||||
bot_tag:
|
||||
description: 'tag/digest reference to a UI container build'
|
||||
required: false
|
||||
default: ':main'
|
||||
worker_tag:
|
||||
description: 'bucket key to fetch worker from'
|
||||
required: false
|
||||
default: '' # Empty will try using current main branch hash
|
||||
|
||||
jobs:
|
||||
deploy_terraform:
|
||||
name: Deploy Terraform
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
deploy_terraform:
|
||||
name: Deploy Terraform
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- uses: hashicorp/setup-terraform@v1.3.2
|
||||
with:
|
||||
terraform_version: ^0.14.0
|
||||
- uses: hashicorp/setup-terraform@v1.3.2
|
||||
with:
|
||||
terraform_version: ^0.14.0
|
||||
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@master
|
||||
with:
|
||||
project_id: ${{ secrets.GCS_PROJECT_ID }}
|
||||
service_account_key: ${{ secrets.GCS_TF_KEY }}
|
||||
export_default_credentials: true
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@master
|
||||
with:
|
||||
project_id: ${{ secrets.GCS_PROJECT_ID }}
|
||||
service_account_key: ${{ secrets.GCS_TF_KEY }}
|
||||
export_default_credentials: true
|
||||
|
||||
- name: Get Google Secrets (they keep them in a box under a tree)
|
||||
id: secrets
|
||||
uses: google-github-actions/get-secretmanager-secrets@main
|
||||
with:
|
||||
secrets: |-
|
||||
secretJSON:${{ secrets.GCS_PROJECT_ID }}/${{github.event.inputs.environment}}-tfvars
|
||||
- name: Get Google Secrets (they keep them in a box under a tree)
|
||||
id: secrets
|
||||
uses: google-github-actions/get-secretmanager-secrets@main
|
||||
with:
|
||||
secrets: |-
|
||||
secretJSON:${{ secrets.GCS_PROJECT_ID }}/${{github.event.inputs.environment}}-tfvars
|
||||
|
||||
- name: Pull necessary artifacts
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
currentHash=${{ github.sha }}
|
||||
targetArtifact=${{ github.event.inputs.worker_tag }}
|
||||
selected="${targetArtifact:-$currentHash}"
|
||||
- name: Pull necessary artifacts
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
currentHash=${{ github.sha }}
|
||||
targetArtifact=${{ github.event.inputs.worker_tag }}
|
||||
selected="${targetArtifact:-$currentHash}"
|
||||
|
||||
mkdir worker-dist
|
||||
gsutil cp gs://roleypoly-artifacts/backend-worker/$selected/script.js worker-dist/backend-worker.js
|
||||
mkdir worker-dist
|
||||
gsutil cp gs://roleypoly-artifacts/backend-worker/$selected/script.js worker-dist/backend-worker.js
|
||||
|
||||
- name: Terraform init
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
terraform init --backend-config "prefix=${{github.event.inputs.environment}}"
|
||||
- name: Terraform init
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
terraform init --backend-config "prefix=${{github.event.inputs.environment}}"
|
||||
|
||||
- name: Write *.auto.tfvars.json files
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
echo \
|
||||
'{"bot_tag": "${{github.event.inputs.bot_tag}}", "api_path_to_worker": "./worker-dist/backend-worker.js"}' \
|
||||
| jq . \
|
||||
| tee tags.auto.tfvars.json
|
||||
- name: Write *.auto.tfvars.json files
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
echo \
|
||||
'{"bot_tag": "${{github.event.inputs.bot_tag}}", "api_path_to_worker": "./worker-dist/backend-worker.js"}' \
|
||||
| jq . \
|
||||
| tee tags.auto.tfvars.json
|
||||
|
||||
echo ${SECRET_TFVARS} > secrets.auto.tfvars.json
|
||||
env:
|
||||
SECRET_TFVARS: ${{ steps.secrets.outputs.secretJSON }}
|
||||
echo ${SECRET_TFVARS} > secrets.auto.tfvars.json
|
||||
env:
|
||||
SECRET_TFVARS: ${{ steps.secrets.outputs.secretJSON }}
|
||||
|
||||
- name: Terraform plan
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
terraform plan \
|
||||
-var-file variables/global.tfvars \
|
||||
-var-file variables/${{github.event.inputs.environment}}.tfvars \
|
||||
-out=./deployment.tfplan
|
||||
- name: Terraform plan
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
terraform plan \
|
||||
-var-file variables/global.tfvars \
|
||||
-var-file variables/${{github.event.inputs.environment}}.tfvars \
|
||||
-out=./deployment.tfplan
|
||||
|
||||
- name: Terraform apply
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
terraform apply \
|
||||
-auto-approve \
|
||||
deployment.tfplan
|
||||
- name: Terraform apply
|
||||
working-directory: ./terraform
|
||||
run: |
|
||||
terraform apply \
|
||||
-auto-approve \
|
||||
deployment.tfplan
|
||||
|
||||
- name: Yell Success at Discord
|
||||
if: success()
|
||||
run: |
|
||||
DATA='{
|
||||
"embeds": [
|
||||
{
|
||||
"title": "Roleypoly Deployment Success",
|
||||
"description": "Roleypoly was successfully deployed at '$(date)'",
|
||||
"color": 4634182,
|
||||
"author": {
|
||||
"name": "Deployment Notification",
|
||||
"url": "https://github.com/roleypoly/roleypoly/actions/runs/${{ github.run_id }}"
|
||||
},
|
||||
"footer": {
|
||||
"text": "GitHub Actions"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
- name: Yell Success at Discord
|
||||
if: success()
|
||||
run: |
|
||||
DATA='{
|
||||
"embeds": [
|
||||
{
|
||||
"title": "Roleypoly Deployment Success",
|
||||
"description": "Roleypoly was successfully deployed at '$(date)'",
|
||||
"color": 4634182,
|
||||
"author": {
|
||||
"name": "Deployment Notification",
|
||||
"url": "https://github.com/roleypoly/roleypoly/actions/runs/${{ github.run_id }}"
|
||||
},
|
||||
"footer": {
|
||||
"text": "GitHub Actions"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
|
||||
curl -X POST -H "content-type: application/json" --data "$DATA" ${{ secrets.DEPLOYMENT_WEBHOOK_URL }}
|
||||
curl -X POST -H "content-type: application/json" --data "$DATA" ${{ secrets.DEPLOYMENT_WEBHOOK_URL }}
|
||||
|
||||
- name: Yell Failure at Discord
|
||||
if: failure()
|
||||
run: |
|
||||
DATA='{
|
||||
"embeds": [
|
||||
{
|
||||
"title": "Roleypoly Deployment Failed",
|
||||
"description": "Roleypoly failed to be deployed at '$(date)'",
|
||||
"color": 15291219,
|
||||
"author": {
|
||||
"name": "Deployment Notification",
|
||||
"url": "https://github.com/roleypoly/roleypoly/actions/runs/${{ github.run_id }}"
|
||||
},
|
||||
"footer": {
|
||||
"text": "GitHub Actions"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
- name: Yell Failure at Discord
|
||||
if: failure()
|
||||
run: |
|
||||
DATA='{
|
||||
"embeds": [
|
||||
{
|
||||
"title": "Roleypoly Deployment Failed",
|
||||
"description": "Roleypoly failed to be deployed at '$(date)'",
|
||||
"color": 15291219,
|
||||
"author": {
|
||||
"name": "Deployment Notification",
|
||||
"url": "https://github.com/roleypoly/roleypoly/actions/runs/${{ github.run_id }}"
|
||||
},
|
||||
"footer": {
|
||||
"text": "GitHub Actions"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
|
||||
curl -X POST -H "content-type: application/json" --data "$DATA" ${{ secrets.DEPLOYMENT_WEBHOOK_URL }}
|
||||
curl -X POST -H "content-type: application/json" --data "$DATA" ${{ secrets.DEPLOYMENT_WEBHOOK_URL }}
|
||||
|
|
88
.github/workflows/dev-container.yml
vendored
88
.github/workflows/dev-container.yml
vendored
|
@ -1,53 +1,53 @@
|
|||
name: Dev Container
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- hack/dockerfiles/dev-container.Dockerfile
|
||||
- .github/workflows/dev-container.yml
|
||||
schedule:
|
||||
- cron: '0 12 * * 2' # 12 noon every tuesday
|
||||
push:
|
||||
paths:
|
||||
- hack/dockerfiles/dev-container.Dockerfile
|
||||
- .github/workflows/dev-container.yml
|
||||
schedule:
|
||||
- cron: '0 12 * * 2' # 12 noon every tuesday
|
||||
jobs:
|
||||
docker_build:
|
||||
name: Docker Build & Publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
docker_build:
|
||||
name: Docker Build & Publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- uses: actions/cache@v2.1.4
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
- uses: actions/cache@v2.1.4
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
with:
|
||||
images: ghcr.io/roleypoly/dev-container
|
||||
tag-sha: true
|
||||
- name: Docker meta
|
||||
id: docker_meta
|
||||
uses: crazy-max/ghaction-docker-meta@v1
|
||||
with:
|
||||
images: ghcr.io/roleypoly/dev-container
|
||||
tag-sha: true
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: Login to GitHub Packages Docker Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: roleypoly
|
||||
password: ${{ secrets.GHCR_PAT }}
|
||||
- name: Login to GitHub Packages Docker Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: roleypoly
|
||||
password: ${{ secrets.GHCR_PAT }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./hack/dockerfiles/dev-container.Dockerfile
|
||||
push: true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./hack/dockerfiles/dev-container.Dockerfile
|
||||
push: true
|
||||
cache-from: type=local,src=/tmp/.buildx-cache
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||
tags: ${{ steps.docker_meta.outputs.tags }}
|
||||
labels: ${{ steps.docker_meta.outputs.labels }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue