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

Migrate from circleci to github actions #44

Merged
merged 26 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
10c9478
#43 Add initial test github action
danielemery Sep 22, 2023
8a91e1a
#43 Split build and test jobs and tidy
danielemery Sep 22, 2023
e125ae0
#43 Remove version from package.json
danielemery Sep 22, 2023
0a4d033
#43 Rename build and test to validate PR and only run on PRs
danielemery Sep 22, 2023
dafa0e1
#43 Create publish job to publish to github container registry on any…
danielemery Sep 22, 2023
47e655e
#43 Replace invalid description with comments
danielemery Sep 22, 2023
10b15b2
#43 Widen regex to account for prerelease versions
danielemery Sep 22, 2023
ab1b17a
#43 Update on tag syntax to match glob specification
danielemery Sep 22, 2023
9258792
#43 Attempt to add helm publish job
danielemery Sep 22, 2023
ade34db
#43 Change helm deploy to use shellbear/helm-release-action
danielemery Sep 22, 2023
5b25456
#43 Fix shellbear version number
danielemery Sep 22, 2023
3640b38
#43 Remove extra $
danielemery Sep 22, 2023
fddf3af
#43 Disable waiting for docker-publish temporarily
danielemery Sep 22, 2023
c50a2fc
#43 Attempt to use old version of aws-actions/configure-aws-credentials
danielemery Sep 23, 2023
edde9f6
#43 Revert previous version bump and fix s3 name
danielemery Sep 23, 2023
eccee9e
#43 Only refer to the tag part of the github ref
danielemery Sep 23, 2023
1884cc0
Attempt to extract just the tag from the github ref
danielemery Sep 23, 2023
599fd0f
#43 Attempt to store version in an env
danielemery Sep 23, 2023
e4455bc
#43 Fix indentation
danielemery Sep 23, 2023
386c379
#43 Use forked version of the helm-release-action
danielemery Sep 23, 2023
da4746c
#43 Test simpler version of helm-release-action
danielemery Sep 23, 2023
af6204d
#43 Update to latest version of helm-release-action
danielemery Sep 23, 2023
b3238bb
#43 Add some debug information
danielemery Sep 23, 2023
4be33cb
#43 Download artifacts into helm directory
danielemery Sep 23, 2023
05c7266
#43 Remove now-superseded circleci config
danielemery Sep 23, 2023
58ba641
#43 Add some basic information in the README about deployment
danielemery Sep 23, 2023
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
147 changes: 0 additions & 147 deletions .circleci/config.yml

This file was deleted.

124 changes: 124 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# 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-api/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.17.1

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
prisma
Dockerfile
.dockerignore
package*.json

- name: Upload helm chart
uses: actions/upload-artifact@v3
with:
name: helm-chart
path: helm

docker-publish:
needs: build
runs-on: ubuntu-latest

steps:
- 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 }}

- 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 }}

helm-publish:
needs:
- build
# - docker-publish
runs-on: ubuntu-latest

steps:
- name: Extract version from github ref
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

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

- name: Print file contents
run: |
ls
ls helm
cat helm/Chart.yaml

- 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: ${{ env.RELEASE_VERSION }}
appVersion: ${{ env.RELEASE_VERSION }}
61 changes: 61 additions & 0 deletions .github/workflows/validate-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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.17.1

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
prisma
Dockerfile
.dockerignore
package*.json

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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# QuizLord API
# Quizlord API

Graphql api for sharing newspaper quizzes between friends, including results and statistics

Follows the [GraphQL Cursor Connections Specification](https://relay.dev/graphql/connections.htm).

# Deployment

The api is packaged in docker and deployed with github actions to the (github registry)[https://github.com/danielemery/quizlord-api/pkgs/container/quizlord-api].
A helm template is also deployed with a github action to https://helm.demery.net.

See (quizlord-stack)[https://github.com/danielemery/quizlord-stack] for further details about deployment and for the terraform module.

# Local Development

Doppler is used to provide access to secrets, in order to run the app you first need to run
Expand Down
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,6 +1,5 @@
{
"name": "@quizlord/api",
"version": "0.4.5",
"description": "Graphql api for sharing newspaper quizzes between friends, including results and statistics",
"main": "index.js",
"engines": {
Expand Down