From 10c94785b05485f5fd7eef569019adcc9fa8646c Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 18:56:36 +0200 Subject: [PATCH 01/26] #43 Add initial test github action --- .github/workflows/test.yaml | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..36e0cb7 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,42 @@ +name: Test + +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + container: + image: cimg/node:18.17.1 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install packages + run: npm ci + + - name: Lint + run: npm run lint + + - name: Run unit tests + run: npm t + + - name: Build + run: npm run build + + - name: Upload Build Artifacts + uses: actions/upload-artifact@v2 + with: + name: build-artifacts + path: | + dist + prisma + Dockerfile + .dockerignore + package*.json From 8a91e1a2edfeeaaded4f6be20adbefb0e04a0577 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 19:39:58 +0200 Subject: [PATCH 02/26] #43 Split build and test jobs and tidy --- .github/workflows/build-and-test.yaml | 62 +++++++++++++++++++++++++++ .github/workflows/test.yaml | 42 ------------------ 2 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 .github/workflows/build-and-test.yaml delete mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..bc105d5 --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,62 @@ +name: Build and test + +on: + push: + branches: ['main'] + 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 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 36e0cb7..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Test - -on: - push: - branches: ['main'] - pull_request: - branches: ['main'] - -permissions: - contents: read - -jobs: - test: - runs-on: ubuntu-latest - container: - image: cimg/node:18.17.1 - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install packages - run: npm ci - - - name: Lint - run: npm run lint - - - name: Run unit tests - run: npm t - - - name: Build - run: npm run build - - - name: Upload Build Artifacts - uses: actions/upload-artifact@v2 - with: - name: build-artifacts - path: | - dist - prisma - Dockerfile - .dockerignore - package*.json From e125ae00eda7aa3aa64cbf4dda057bb0e95bc928 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 19:43:51 +0200 Subject: [PATCH 03/26] #43 Remove version from package.json Tags will be used as the sole mechanism for versions --- package-lock.json | 2 -- package.json | 1 - 2 files changed, 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93dae77..593ce1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,10 @@ { "name": "@quizlord/api", - "version": "0.4.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quizlord/api", - "version": "0.4.5", "license": "MIT", "dependencies": { "@apollo/server": "^4.7.1", diff --git a/package.json b/package.json index 28f032e..30340d3 100644 --- a/package.json +++ b/package.json @@ -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": { From 0a4d03319d58eaa5c162bb0cbf220f630f7b8be6 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 20:08:14 +0200 Subject: [PATCH 04/26] #43 Rename build and test to validate PR and only run on PRs --- .github/workflows/{build-and-test.yaml => validate-pr.yaml} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{build-and-test.yaml => validate-pr.yaml} (90%) diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/validate-pr.yaml similarity index 90% rename from .github/workflows/build-and-test.yaml rename to .github/workflows/validate-pr.yaml index bc105d5..a452e76 100644 --- a/.github/workflows/build-and-test.yaml +++ b/.github/workflows/validate-pr.yaml @@ -1,8 +1,8 @@ -name: Build and test +name: Validate PR +description: | + This workflow validates pull requests by running unit tests and linting. on: - push: - branches: ['main'] pull_request: branches: ['main'] From dafa0e1d5c4a1c5a826dd98e6deb5122be1cab6e Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 20:13:35 +0200 Subject: [PATCH 05/26] #43 Create publish job to publish to github container registry on any tag push --- .github/workflows/publish.yml | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7e0f7be --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,78 @@ +name: Publish +description: | + 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). + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + +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 + + 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 }} From 47e655e85e2de208246c2ef1f28d645dfa70e36e Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 20:16:35 +0200 Subject: [PATCH 06/26] #43 Replace invalid description with comments --- .github/workflows/publish.yml | 8 ++++---- .github/workflows/validate-pr.yaml | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7e0f7be..c6f018a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,8 @@ +# 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 -description: | - 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). on: push: diff --git a/.github/workflows/validate-pr.yaml b/.github/workflows/validate-pr.yaml index a452e76..5cf8452 100644 --- a/.github/workflows/validate-pr.yaml +++ b/.github/workflows/validate-pr.yaml @@ -1,6 +1,5 @@ +# This workflow validates pull requests by running unit tests and linting. name: Validate PR -description: | - This workflow validates pull requests by running unit tests and linting. on: pull_request: From 10b15b24129fb8768b8447c49264aa398a9fba35 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 20:29:40 +0200 Subject: [PATCH 07/26] #43 Widen regex to account for prerelease versions --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c6f018a..7da021b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,7 @@ name: Publish on: push: tags: - - "v[0-9]+.[0-9]+.[0-9]+" + - "v[0-9]+\.[0-9]+\.[0-9]+.*" permissions: packages: write From ab1b17a9fbec600306b8955b71899d7075b505ea Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 20:36:37 +0200 Subject: [PATCH 08/26] #43 Update on tag syntax to match glob specification --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7da021b..df0d14c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,7 @@ name: Publish on: push: tags: - - "v[0-9]+\.[0-9]+\.[0-9]+.*" + - "v[0-9]+.[0-9]+.[0-9]+*" permissions: packages: write From 9258792606dad3012b90778700fea2255556ac7f Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 21:10:53 +0200 Subject: [PATCH 09/26] #43 Attempt to add helm publish job --- .github/workflows/publish.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index df0d14c..f693776 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -9,6 +9,9 @@ on: 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 @@ -46,6 +49,12 @@ jobs: .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 @@ -76,3 +85,34 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + helm-publish: + needs: + - build + - docker-publish + runs-on: ubuntu-latest + container: + image: hypnoglow/helm-s3:master-helm3.11 + env: + AWS_ACCESS_KEY_ID: ${{ secrets.HELM_DEPLOY_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.HELM_DEPLOY_SECRET }} + AWS_DEFAULT_REGION: $${{ vars.HELM_DEPLOY_REGION }} + + steps: + - name: Download chart definition + uses: actions/download-artifact@v3 + with: + name: helm-chart + + - name: Add repo + run: | + helm repo add demery-s3 s3://helm.demery.net + helm repo list + + - name: Package chart + run: | + helm package ./helm --version=${{ github.ref_name }} --app-version=${{ github.ref_name }} + + - name: Publish chart + run: | + helm s3 push --relative ./quizlord-api-${{ github.ref_name }}.tgz demery-s3 From ade34db4ca58f6a0cc3f888657103f85383d7c7e Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 21:37:32 +0200 Subject: [PATCH 10/26] #43 Change helm deploy to use shellbear/helm-release-action --- .github/workflows/publish.yml | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f693776..29bc2c8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -91,12 +91,6 @@ jobs: - build - docker-publish runs-on: ubuntu-latest - container: - image: hypnoglow/helm-s3:master-helm3.11 - env: - AWS_ACCESS_KEY_ID: ${{ secrets.HELM_DEPLOY_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.HELM_DEPLOY_SECRET }} - AWS_DEFAULT_REGION: $${{ vars.HELM_DEPLOY_REGION }} steps: - name: Download chart definition @@ -104,15 +98,16 @@ jobs: with: name: helm-chart - - name: Add repo - run: | - helm repo add demery-s3 s3://helm.demery.net - helm repo list - - - name: Package chart - run: | - helm package ./helm --version=${{ github.ref_name }} --app-version=${{ github.ref_name }} + - 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 - run: | - helm s3 push --relative ./quizlord-api-${{ github.ref_name }}.tgz demery-s3 + uses: shellbear/helm-release-action@0.1 + with: + repo: s3://demery-s3/ + chart: ./helm + version: ${{ github.ref }} From 5b2545689ba6f467ebb2fdef34a7fcbb3561df4a Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 21:41:57 +0200 Subject: [PATCH 11/26] #43 Fix shellbear version number --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 29bc2c8..22f960c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -106,7 +106,7 @@ jobs: aws-region: $${{ vars.HELM_DEPLOY_REGION }} - name: Publish chart - uses: shellbear/helm-release-action@0.1 + uses: shellbear/helm-release-action@v0.1 with: repo: s3://demery-s3/ chart: ./helm From 3640b387fcd6aedaeef4303a8f8b836b857d5a4c Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 21:44:19 +0200 Subject: [PATCH 12/26] #43 Remove extra $ --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 22f960c..d18caf1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -103,7 +103,7 @@ jobs: with: aws-access-key-id: ${{ secrets.HELM_DEPLOY_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.HELM_DEPLOY_SECRET }} - aws-region: $${{ vars.HELM_DEPLOY_REGION }} + aws-region: ${{ vars.HELM_DEPLOY_REGION }} - name: Publish chart uses: shellbear/helm-release-action@v0.1 From fddf3af3b6fe903c26319124c274ba9918972016 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Fri, 22 Sep 2023 22:31:59 +0200 Subject: [PATCH 13/26] #43 Disable waiting for docker-publish temporarily --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d18caf1..e633f53 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -89,7 +89,7 @@ jobs: helm-publish: needs: - build - - docker-publish + # - docker-publish runs-on: ubuntu-latest steps: From c50a2fcb7982d01bda9a9d082e6414af5d3fb23e Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:05:18 +0200 Subject: [PATCH 14/26] #43 Attempt to use old version of aws-actions/configure-aws-credentials --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e633f53..dc55b72 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -99,7 +99,7 @@ jobs: name: helm-chart - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.HELM_DEPLOY_ACCESS_KEY }} aws-secret-access-key: ${{ secrets.HELM_DEPLOY_SECRET }} From edde9f63ba3098cdecad8ef0d81bfee0e108eff3 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:14:24 +0200 Subject: [PATCH 15/26] #43 Revert previous version bump and fix s3 name --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dc55b72..22bd3b1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -99,7 +99,7 @@ jobs: name: helm-chart - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 + 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 }} @@ -108,6 +108,6 @@ jobs: - name: Publish chart uses: shellbear/helm-release-action@v0.1 with: - repo: s3://demery-s3/ + repo: s3://helm.demery.net/ chart: ./helm version: ${{ github.ref }} From eccee9ec4d0af2f9c5fc13c2d4a0780b3ef9e9c1 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:25:54 +0200 Subject: [PATCH 16/26] #43 Only refer to the tag part of the github ref --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 22bd3b1..f72fb42 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -110,4 +110,4 @@ jobs: with: repo: s3://helm.demery.net/ chart: ./helm - version: ${{ github.ref }} + version: ${{ replace(github.ref, 'refs/tags/', '') }} From 1884cc04772eac2bc1134ff40f253bb25a7f2ffa Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:31:27 +0200 Subject: [PATCH 17/26] Attempt to extract just the tag from the github ref --- .github/workflows/publish.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f72fb42..4540189 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -93,6 +93,9 @@ jobs: runs-on: ubuntu-latest steps: + - name: Extract version from github ref + run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + - name: Download chart definition uses: actions/download-artifact@v3 with: @@ -110,4 +113,4 @@ jobs: with: repo: s3://helm.demery.net/ chart: ./helm - version: ${{ replace(github.ref, 'refs/tags/', '') }} + version: ${{ steps.vars.outputs.tag }} From 599fd0f113fcad6bfaa41f986fb1a84eaa122ed1 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:33:40 +0200 Subject: [PATCH 18/26] #43 Attempt to store version in an env --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4540189..fe638c9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -94,7 +94,7 @@ jobs: steps: - name: Extract version from github ref - run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV - name: Download chart definition uses: actions/download-artifact@v3 @@ -113,4 +113,4 @@ jobs: with: repo: s3://helm.demery.net/ chart: ./helm - version: ${{ steps.vars.outputs.tag }} + version: ${{ env.RELEASE_VERSION }} From e4455bc83eadcd923793041167bdb37a993fdb98 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:35:00 +0200 Subject: [PATCH 19/26] #43 Fix indentation --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fe638c9..0423494 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -113,4 +113,4 @@ jobs: with: repo: s3://helm.demery.net/ chart: ./helm - version: ${{ env.RELEASE_VERSION }} + version: ${{ env.RELEASE_VERSION }} From 386c379dc0097900a9b239fe0129ac075a15a421 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:47:26 +0200 Subject: [PATCH 20/26] #43 Use forked version of the helm-release-action --- .github/workflows/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0423494..755dac6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -109,8 +109,9 @@ jobs: aws-region: ${{ vars.HELM_DEPLOY_REGION }} - name: Publish chart - uses: shellbear/helm-release-action@v0.1 + uses: danielemery/helm-release-action@414c0cb70b55f95a804d00a03f329110c1fc05c1 with: repo: s3://helm.demery.net/ chart: ./helm version: ${{ env.RELEASE_VERSION }} + appVersion: ${{ env.RELEASE_VERSION }} From da4746c93e32ddf427ada62f31ffb879e14d4fa1 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 14:59:04 +0200 Subject: [PATCH 21/26] #43 Test simpler version of helm-release-action --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 755dac6..ae0e6d1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -109,7 +109,7 @@ jobs: aws-region: ${{ vars.HELM_DEPLOY_REGION }} - name: Publish chart - uses: danielemery/helm-release-action@414c0cb70b55f95a804d00a03f329110c1fc05c1 + uses: danielemery/helm-release-action@9457cccde878836aa47ad5fd0c3f9759753d50f6 with: repo: s3://helm.demery.net/ chart: ./helm From af6204d3b7aee978f67e4acbba4a507d85c0d779 Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 15:04:31 +0200 Subject: [PATCH 22/26] #43 Update to latest version of helm-release-action --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae0e6d1..05c3901 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -109,7 +109,7 @@ jobs: aws-region: ${{ vars.HELM_DEPLOY_REGION }} - name: Publish chart - uses: danielemery/helm-release-action@9457cccde878836aa47ad5fd0c3f9759753d50f6 + uses: danielemery/helm-release-action@f19adb815088a067bb839b224decb0611072652d with: repo: s3://helm.demery.net/ chart: ./helm From b3238bb88680bb4a87038a8a52d893ce8d9a788d Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 15:11:52 +0200 Subject: [PATCH 23/26] #43 Add some debug information --- .github/workflows/publish.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 05c3901..1f8b0a4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -101,6 +101,12 @@ jobs: with: name: helm-chart + - name: Print file contents + run: | + ls + ls helm + cat helm/Chart.yaml + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: From 4be33cb853bfa5e5d0768855484c27342128421f Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 15:17:41 +0200 Subject: [PATCH 24/26] #43 Download artifacts into helm directory --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1f8b0a4..faccd16 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -100,6 +100,7 @@ jobs: uses: actions/download-artifact@v3 with: name: helm-chart + path: helm - name: Print file contents run: | From 05c726619cb523abf54588b34156b73728c8f54e Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 15:21:45 +0200 Subject: [PATCH 25/26] #43 Remove now-superseded circleci config --- .circleci/config.yml | 147 ------------------------------------------- 1 file changed, 147 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index fc9f0b4..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,147 +0,0 @@ -version: 2.1 - -jobs: - test: - docker: - - image: cimg/node:16.15 - steps: - - checkout - - run: - name: Install Packages - command: | - npm ci - - run: - name: Lint - command: | - npm run lint - - run: - name: Run Unit Tests - command: | - npm t - - run: - name: Build - command: | - npm run build - - persist_to_workspace: - root: . - paths: - - dist - - prisma - - Dockerfile - - .dockerignore - - package*.json - - publish-helm: - docker: - - image: hypnoglow/helm-s3:master-helm3.4 - shell: /bin/sh -leo pipefail - environment: - - BASH_ENV: /etc/profile - steps: - - checkout - - run: - name: Setup Environment Variables - command: | - TAG="${CIRCLE_TAG:1}" - echo $TAG - echo "export TAG=$TAG" >> $BASH_ENV - - run: - name: Add Repo - command: | - helm repo add demery-s3 s3://helm.demery.net - helm repo list - - run: - name: Package Chart - command: | - helm package ./helm --version=$TAG --app-version=$TAG - - run: - name: Publish Chart - command: | - helm s3 push --relative ./quizlord-api-$TAG.tgz demery-s3 - - publish: - machine: true - steps: - - attach_workspace: - at: . - - run: - name: Setup Environment Variables - command: | - REGISTRY=$DOCKER_REGISTRY_URL/$DOCKER_REPOSITORY_API - echo "export REGISTRY=$REGISTRY" >> $BASH_ENV - TAG=$CIRCLE_TAG - echo $TAG - echo "export TAG=$TAG" >> $BASH_ENV - - run: - name: Run Docker Build - command: | - echo $REGISTRY:$TAG | base64 - docker build -t $REGISTRY:$TAG --build-arg IMAGE_VERSION=$TAG . - - run: - name: Push Docker Image - command: | - echo $CR_PAT | docker login $DOCKER_REGISTRY_URL -u $DOCKER_USERNAME --password-stdin - docker push $REGISTRY:$TAG - publish-latest: - machine: true - steps: - - attach_workspace: - at: . - - run: - name: Setup Environment Variables - command: | - REGISTRY=$DOCKER_REGISTRY_URL/$DOCKER_REPOSITORY_API - echo $REGISTRY - echo "export REGISTRY=$REGISTRY" >> $BASH_ENV - TAG=$CIRCLE_TAG - echo $TAG - echo "export TAG=$TAG" >> $BASH_ENV - - run: - name: Run Docker Build - command: | - docker build -t $REGISTRY:$TAG --build-arg IMAGE_VERSION=$TAG . - docker tag $REGISTRY:$TAG $REGISTRY:latest - - run: - name: Push Docker Image - command: | - echo $CR_PAT | docker login $DOCKER_REGISTRY_URL -u $DOCKER_USERNAME --password-stdin - docker push $REGISTRY:$TAG - docker push $REGISTRY:latest -workflows: - version: 2 - ci: - jobs: - - test: - filters: - tags: - only: /.*/ - - - publish: - requires: - - test - filters: - tags: - only: /v([0-9])*.([0-9])*.([0-9])*-.*/ - branches: - ignore: /.*/ - context: quizlord - - - publish-latest: - requires: - - test - filters: - tags: - only: /v([0-9])*.([0-9])*.([0-9])*/ - branches: - ignore: /.*/ - context: quizlord - - - publish-helm: - requires: - - test - filters: - tags: - only: /v([0-9])*.([0-9])*.([0-9])*.*/ - branches: - ignore: /.*/ - context: demery-helm-deploy From 58ba641d439d0252ec2004dab863e3a2429ff82e Mon Sep 17 00:00:00 2001 From: Daniel Emery Date: Sat, 23 Sep 2023 15:35:24 +0200 Subject: [PATCH 26/26] #43 Add some basic information in the README about deployment --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9179d4b..9cddef4 100644 --- a/README.md +++ b/README.md @@ -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