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

Switch to Github Actions for all deployments #6

Merged
merged 9 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
152 changes: 0 additions & 152 deletions .circleci/config.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/lookaside.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: GCS Lookaside

on:
push:
branches-ignore:
- main

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
- name: Prepare npmrc
run: envsubst < ci.npmrc > .npmrc
env:
ARTIFACTORY_TOKEN: '${{ secrets.ARTIFACTORY_TOKEN }}'
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Build project
run: npm run build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: website
path: dist

# Deployment job
deploy:
environment:
name: google-cloud-storage
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: website
path: dist
- name: Prepare npmrc
run: envsubst < ci.npmrc > .npmrc
env:
ARTIFACTORY_TOKEN: '${{ secrets.ARTIFACTORY_TOKEN }}'
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Add service key
env:
GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }}
run: echo "$GCLOUD_SERVICE_KEY" > "gcloud-service-key.json"
- name: Deploy to Google Cloud Storage
id: deployment
run: node scripts/lookaside.mjs --keyFilename=gcloud-service-key.json --branch ${{ github.ref_name }}
82 changes: 42 additions & 40 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
name: Build and deploy website to GitHub Pages
name: GitHub Pages

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
push:
branches:
- main
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false
group: 'pages'
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Setup Node
uses: actions/setup-node@v4
- name: Prepare npmrc
run: envsubst < ci.npmrc > .npmrc
env:
ARTIFACTORY_TOKEN: '${{ secrets.ARTIFACTORY_TOKEN }}'
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Build project
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Setup Node
uses: actions/setup-node@v4
- name: Prepare npmrc
run: envsubst < ci.npmrc > .npmrc
env:
ARTIFACTORY_TOKEN: '${{ secrets.ARTIFACTORY_TOKEN }}'
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Build project
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
8 changes: 7 additions & 1 deletion scripts/lookaside.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Storage } from '@google-cloud/storage';
import path from 'node:path';
import fs from 'node:fs';
import os from 'node:os';
import read from 'fs-readdir-recursive';
import minimist from 'minimist';
import logSymbols from 'log-symbols';
Expand Down Expand Up @@ -44,7 +45,12 @@ async function run() {
});

await Promise.all(uploads);
console.log(logSymbols.success, 'Lookaside deployed');

const url = `https://storage.googleapis.com/prism-design-system/${branch}/index.html`;
const output = process.env['GITHUB_OUTPUT'];

fs.appendFileSync(output, `page_url=${url}${os.EOL}`);
console.log(logSymbols.success, `Lookaside deployed at ${url}`);
} catch (error) {
console.log(logSymbols.error, error);
process.exit(1);
Expand Down
Loading