Skip to content

Commit

Permalink
Replace CircleCi with Github Actions (#39)
Browse files Browse the repository at this point in the history
* #37 Replace circleci test job with github actions Validate PR workflow
* #37 Add docker and helm publish job
* #37 Remove version from package files
* #37 Remove now-redundant circleci job
  • Loading branch information
danielemery authored Oct 7, 2023
1 parent f161296 commit 85582b0
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 149 deletions.
146 changes: 0 additions & 146 deletions .circleci/config.yml

This file was deleted.

127 changes: 127 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# This workflow publishes the Docker image to the GitHub Container Registry and the Helm chart to the appropriate s3 bucket.
# It's triggered when a new tag is pushed to the repository, this can either be in main (as a release tag) or in a feature
# branch (as a prerelease tag).

name: Publish

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

# Note this alone is not enough to give the action write access
# In the registry settings https://github.com/users/danielemery/packages/container/quizlord-client/settings
# you must also add the action with write access under Manage actions access
permissions:
packages: write

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
NODE_VERSION: 18.16.0

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install packages
run: npm ci

- name: Build
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
dist
env.schema.js
Dockerfile
.dockerignore
- name: Upload helm chart
uses: actions/upload-artifact@v3
with:
name: helm-chart
path: helm

docker-publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'

- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=${{ steps.version.outputs.is_stable == 'true' && 'true' || 'false' }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
IMAGE_VERSION=${{ steps.version.outputs.full }}
helm-publish:
needs:
- build
- docker-publish
runs-on: ubuntu-latest

steps:
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'

- name: Download chart definition
uses: actions/download-artifact@v3
with:
name: helm-chart
path: helm

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.HELM_DEPLOY_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.HELM_DEPLOY_SECRET }}
aws-region: ${{ vars.HELM_DEPLOY_REGION }}

- name: Publish chart
uses: danielemery/helm-release-action@f19adb815088a067bb839b224decb0611072652d
with:
repo: s3://helm.demery.net/
chart: ./helm
version: ${{ steps.version.outputs.full }}
appVersion: ${{ steps.version.outputs.full }}
60 changes: 60 additions & 0 deletions .github/workflows/validate-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This workflow validates pull requests by running unit tests and linting.
name: Validate PR

on:
pull_request:
branches: ['main']

permissions:
contents: read

env:
NODE_VERSION: 18.16.0

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install packages
run: npm ci

- name: Build
run: npm run build

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
dist
env.schema.js
Dockerfile
.dockerignore
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install packages
run: npm ci

- name: Lint
run: npm run lint

- name: Run unit tests
run: npm t
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@quizlord/client",
"private": true,
"version": "0.7.2",
"engines": {
"node": "v18.16.0"
},
Expand Down

0 comments on commit 85582b0

Please sign in to comment.