-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start work to set up an automated staging deploy
- Loading branch information
Showing
1 changed file
with
21 additions
and
16 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,5 +1,5 @@ | ||
name: CI | ||
on: [workflow_dispatch] | ||
on: [push, workflow_dispatch] | ||
jobs: | ||
build: | ||
name: Build & test | ||
|
@@ -10,11 +10,9 @@ jobs: | |
# Install Node 14 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 14 | ||
node-version: 20.11.1 | ||
cache: 'npm' | ||
|
||
- run: npm install -g [email protected] | ||
|
||
# Install & build & test: | ||
- run: npm ci | ||
|
||
|
@@ -24,30 +22,34 @@ jobs: | |
run: npm run build | ||
env: | ||
NODE_ENV: development | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Build with secrets for production, on push only: | ||
- name: Build for production | ||
if: github.event_name == 'push' | ||
run: npm run build | ||
env: | ||
NODE_ENV: production | ||
GATSBY_POSTHOG_KEY: ${{ secrets.GATSBY_POSTHOG_KEY }} | ||
NEXT_PUBLIC_POSTHOG_KEY: ${{ vars.POSTHOG_KEY }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: public | ||
path: public/* | ||
name: out | ||
path: out/* | ||
if-no-files-found: error | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: rss | ||
path: public/rss.xml | ||
path: out/rss.xml | ||
if-no-files-found: error | ||
|
||
check-blog-changes: | ||
name: Check for new blog posts to announce | ||
if: github.event_name == 'push' | ||
if: false | ||
# TODO: Put back to `github.event_name == 'push' && github.ref == 'refs/heads/main'` after | ||
# the big site switchover is done, with some careful testing | ||
runs-on: ubuntu-latest | ||
needs: build | ||
outputs: | ||
|
@@ -102,8 +104,8 @@ jobs: | |
|
||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: public | ||
path: public | ||
name: out | ||
path: out | ||
|
||
- uses: docker/setup-buildx-action@v2 | ||
- name: Login to DockerHub | ||
|
@@ -119,8 +121,9 @@ jobs: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
images: httptoolkit/website | ||
tags: | | ||
type=raw,value=prod,enable={{is_default_branch}} | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=raw,value=prod,enable=${{ github.ref == 'refs/heads/main' }} | ||
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||
type=raw,value=staging,enable=${{ github.ref == 'refs/heads/next' }} | ||
type=sha | ||
- name: Publish to Docker Hub | ||
|
@@ -132,8 +135,8 @@ jobs: | |
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
publish-scaleway: | ||
name: Deploy to Scaleway | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
name: Deploy to Scaleway ${{ vars.GHA_DEPLOY_ENV_NAME }} | ||
if: github.event_name == 'push' && vars.GHA_DEPLOY_ENV_NAME | ||
environment: production | ||
runs-on: ubuntu-latest | ||
needs: publish-docker | ||
|
@@ -148,13 +151,15 @@ jobs: | |
|
||
- name: Redeploy failover container | ||
uses: thibaultchazal/scaleway-serverless-container-deploy-action@0d290edda0c3359e51442bd8bf730eafef4e290f | ||
if: ${{ vars.SCW_FAILOVER_API_CONTAINER_ID }} | ||
with: | ||
container_id: ${{ vars.SCW_FAILOVER_API_CONTAINER_ID }} | ||
region: ${{ vars.SCW_FAILOVER_API_CONTAINER_REGION }} | ||
secret_key: ${{ secrets.SCW_SECRET_KEY }} | ||
registry_image_url: "registry.hub.docker.com/httptoolkit/website:prod" | ||
|
||
- name: Flush CDN cache | ||
if: ${{ vars.BUNNY_PULL_ZONE_ID }} | ||
run: | | ||
# Wait a little - the reploy command doesn't wait for the container to start up | ||
sleep 30 | ||
|
@@ -164,7 +169,7 @@ jobs: | |
--url https://api.bunny.net/pullzone/$PULL_ZONE_ID/purgeCache \ | ||
--header "AccessKey: $BUNNY_SITE_API_KEY" | ||
env: | ||
PULL_ZONE_ID: 960393 | ||
PULL_ZONE_ID: ${{ vars.BUNNY_PULL_ZONE_ID }} | ||
BUNNY_SITE_API_KEY: ${{ secrets.BUNNY_SITE_API_KEY }} | ||
|
||
announce-blog-changes: | ||
|