Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic prod deployments #8

Merged
merged 8 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Thrershold Website CI

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: "16"
cache: "yarn"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build preview
if: github.event_name == 'pull_request'
run: yarn build
env:
PUBLIC_URL: /${{ github.head_ref }}

- name: Build
if: github.event_name == 'push'
run: yarn build
env:
PUBLIC_URL: /

- uses: actions/upload-artifact@v2
with:
name: build
path: build

deploy-preview:
name: Deploy preview
needs: build
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v2

- name: Deploy PR to GCP
uses: thesis/gcp-storage-bucket-action@v3.1.0
with:
service-key: ${{ secrets.MAINNET_PREVIEW_UPLOADER_SERVICE_KEY_JSON_BASE64 }}
project: ${{ secrets.MAINNET_PREVIEW_GOOGLE_PROJECT_ID }}
nkuba marked this conversation as resolved.
Show resolved Hide resolved
bucket-name: preview.threshold.network
bucket-path: ${{ github.head_ref }}
build-folder: build

- name: Post preview URL to PR
uses: actions/github-script@v5
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Preview uploaded to https://preview.threshold.network/${{ github.head_ref }}/index.html.'
})

deploy:
name: Deploy
needs: build
if: github.event_name == 'push'
r-czajkowski marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v2

- name: Deploy build to GCP
uses: thesis/gcp-storage-bucket-action@v3.1.0
with:
service-key: ${{ secrets.MAINNET_UPLOADER_SERVICE_KEY_JSON_BASE64 }}
project: ${{ secrets.MAINNET_GOOGLE_PROJECT_ID }}
nkuba marked this conversation as resolved.
Show resolved Hide resolved
bucket-name: threshold.network
build-folder: build
set-website: true
home-page-path: index.html
error-page-path: index.html
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github/workflows/ci.yaml @pdyraga @nkuba @lukasz-zimnoch