From 86112ccf0a0c3df4a119cfd21e221e0fc357a14b Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 10:35:13 +0200 Subject: [PATCH 01/41] Initial build CI --- .github/workflows/ci-master.yml | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/ci-master.yml diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml new file mode 100644 index 0000000..3e709f5 --- /dev/null +++ b/.github/workflows/ci-master.yml @@ -0,0 +1,35 @@ +on: + push: + branches: + - master + pull_request: + branches: + - master + types: [opened, reopened, synchronize] + +name: ci-master + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + # - uses: actions/cache@v3 + # with: + # path: | + # ~/.cache/pip + # ~/.platformio/cache + # key: ${{ runner.os }}-arch + + - uses: actions/setup-node@v4 + with: + python-version: 17.x + + - name: Install dependencies + run: npm ci + + - name: Build + run: nmp run build --if-present From c88eae4fde4cfdbad089a141c8e7e147e61a50d0 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 10:41:50 +0200 Subject: [PATCH 02/41] Fix setup-node CI task --- .github/workflows/ci-master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 3e709f5..638bdf2 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -24,9 +24,9 @@ jobs: # ~/.platformio/cache # key: ${{ runner.os }}-arch - - uses: actions/setup-node@v4 + - uses: actions/setup-node@v3 with: - python-version: 17.x + node-version: 17.x - name: Install dependencies run: npm ci From 41de63a0a535ef40b5f8b079ced88f8395f1422f Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 10:42:52 +0200 Subject: [PATCH 03/41] Fix typo from 'nmp' to 'npm' in CI build phase --- .github/workflows/ci-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 638bdf2..8efe077 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -32,4 +32,4 @@ jobs: run: npm ci - name: Build - run: nmp run build --if-present + run: npm run build --if-present From 641ed6ad6745a24a2066734ccd9017fc8b1dc019 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 10:54:49 +0200 Subject: [PATCH 04/41] Add Dockerfile and build-push to CI --- .github/workflows/ci-master.yml | 35 ++++++++++++++++++++++++++------- Dockerfile | 2 ++ 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 8efe077..412533d 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -9,6 +9,10 @@ on: name: ci-master +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: build: @@ -17,13 +21,6 @@ jobs: steps: - uses: actions/checkout@v3 - # - uses: actions/cache@v3 - # with: - # path: | - # ~/.cache/pip - # ~/.platformio/cache - # key: ${{ runner.os }}-arch - - uses: actions/setup-node@v3 with: node-version: 17.x @@ -33,3 +30,27 @@ jobs: - name: Build run: npm run build --if-present + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to 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@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.output.tags }} + labels: ${{ steps.meta.output.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..410596b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:1-alpine +COPY dist /usr/share/nginx/html From c5079a4b9320f2a2aaae8a617dfcae6f6f33eb0e Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 10:58:40 +0200 Subject: [PATCH 05/41] Add tags to containers in ci-master --- .github/workflows/ci-master.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 412533d..907c9bf 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -12,6 +12,7 @@ name: ci-master env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + TARGET_ENV: production jobs: @@ -46,6 +47,13 @@ jobs: uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} + type=ref,event=tag + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} - name: Build and push uses: docker/build-push-action@v5 @@ -53,4 +61,4 @@ jobs: context: . push: true tags: ${{ steps.meta.output.tags }} - labels: ${{ steps.meta.output.labels }} \ No newline at end of file + labels: ${{ steps.meta.output.labels }} From 245f6db6ec3383a7f1d5dccf5091c5c41a2a1a96 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:02:02 +0200 Subject: [PATCH 06/41] Attempt to fix container tagging on master branch --- .github/workflows/ci-master.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 907c9bf..eda6d62 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -44,16 +44,12 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }} - type=ref,event=tag - type=ref,event=branch + type=ref,event=push type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - name: Build and push uses: docker/build-push-action@v5 From d4584ff6fc13d4698fac26aa0d0809241ef93781 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:05:07 +0200 Subject: [PATCH 07/41] Second attempt to fix branch tagging --- .github/workflows/ci-master.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index eda6d62..0210bde 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -9,6 +9,8 @@ on: name: ci-master +# REGISTRY and IMAGE_NAME are for building and tagging the container. +# TARGET_ENV is used by Webpack to determine the build target. env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} @@ -48,8 +50,7 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=ref,event=push - type=ref,event=pr + type=ref,event=branch - name: Build and push uses: docker/build-push-action@v5 From a3dee1aba0417d7065743dbb501d452173e9f666 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:07:14 +0200 Subject: [PATCH 08/41] Third attempt to fix container image tagging --- .github/workflows/ci-master.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 0210bde..7be1e9d 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -49,10 +49,8 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - - name: Build and push + - name: Build and push container uses: docker/build-push-action@v5 with: context: . From 27ed6055fb55edc55af84f66fb748bbe58d4e43f Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:13:59 +0200 Subject: [PATCH 09/41] Add edge tag and PR tag to master --- .github/workflows/ci-master.yml | 7 +++-- .github/workflows/push-release.yml | 48 ++++++++++++++++++++++++++++++ .github/workflows/push-tag.yml | 0 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/push-release.yml create mode 100644 .github/workflows/push-tag.yml diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 7be1e9d..73b5812 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -49,11 +49,14 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=edge,branch=master + type=ref,event=pr - - name: Build and push container + - name: Build image uses: docker/build-push-action@v5 with: context: . - push: true + push: false tags: ${{ steps.meta.output.tags }} labels: ${{ steps.meta.output.labels }} diff --git a/.github/workflows/push-release.yml b/.github/workflows/push-release.yml new file mode 100644 index 0000000..0b9db53 --- /dev/null +++ b/.github/workflows/push-release.yml @@ -0,0 +1,48 @@ +on: + release: + types: [published] + +name: push-release + +jobs: + + # Copied verbatim from https://docs.platformio.org/en/stable/integration/ci/github-actions.html + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: 17.x + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build --if-present + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to 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 + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.output.tags }} + labels: ${{ steps.meta.output.labels }} diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml new file mode 100644 index 0000000..e69de29 From a202fc97d902e20738fd6ae2f2c32d1661ac47c1 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:15:12 +0200 Subject: [PATCH 10/41] Re-enable pushing of container image --- .github/workflows/ci-master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 73b5812..0926eb2 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -57,6 +57,6 @@ jobs: uses: docker/build-push-action@v5 with: context: . - push: false + push: true tags: ${{ steps.meta.output.tags }} labels: ${{ steps.meta.output.labels }} From 0fc690eb4aaaf800ab461e402662bf2638eaa5ba Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:19:35 +0200 Subject: [PATCH 11/41] Fix missing s when referencing determined tags --- .github/workflows/ci-master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 0926eb2..9cdb5d4 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -58,5 +58,5 @@ jobs: with: context: . push: true - tags: ${{ steps.meta.output.tags }} - labels: ${{ steps.meta.output.labels }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 8f6d204b29245caa94c97ece49750ec1250c8b51 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:25:32 +0200 Subject: [PATCH 12/41] Add branch name tag container tag --- .github/workflows/ci-master.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 9cdb5d4..c2def8d 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -50,13 +50,14 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=edge,branch=master + type=raw,value={{branch}},enabled={{is_default_branch}} + type=ref,event=branch type=ref,event=pr - name: Build image uses: docker/build-push-action@v5 with: context: . - push: true + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 77139e597d5c0e5b13f5ec091427722a684e404d Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:28:59 +0200 Subject: [PATCH 13/41] Add Github CI to dependabot and update IMAGE_NAME variable --- .github/dependabot.yml | 12 ++++++++++-- .github/workflows/ci-master.yml | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 000d73e..7f1f5d4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,15 @@ version: 2 updates: - - package-ecosystem: "npm" # See documentation for possible values - directory: "/" # Location of package manifests + + # Check for Github Actions version updates (for CI/CD) + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + # Check for npm package updates + - package-ecosystem: "npm" + directory: "/" schedule: interval: "daily" diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index c2def8d..628b806 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -13,7 +13,7 @@ name: ci-master # TARGET_ENV is used by Webpack to determine the build target. env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui TARGET_ENV: production jobs: From 11a924885e0419461e5a40e2cadf79276d6cc40b Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:40:19 +0200 Subject: [PATCH 14/41] Add push-tag CI to upload artifacts and tag container --- .github/workflows/push-tag.yml | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index e69de29..752f7cb 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -0,0 +1,72 @@ +on: + push: + tags: + - 'v*' + +name: push-tag + +# REGISTRY and IMAGE_NAME are for building and tagging the container. +# TARGET_ENV is used by Webpack to determine the build target. +env: + REGISTRY: ghcr.io + ARTIFACT_NAME: shocklink-webui.zip + IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui + TARGET_ENV: production + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: 17.x + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build --if-present + + # This step differs from the main CI. + - name: Compress the artifacts + run: zip -r ${{ env.ARTIFACT_NAME }} dist + + # This step differs from the main CI. + - name: Upload artifacts + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ env.ARTIFACT_NAME }} + asset_name: ${{ env.ARTIFACT_NAME }} + tag: ${{ github.ref }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # This step differs from the main CI. + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=tag + + - name: Build image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 2c8475fe8e8d4954777014a28f417f8f03165298 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:48:01 +0200 Subject: [PATCH 15/41] Split up push-tag CI into seperate steps --- .github/workflows/push-tag.yml | 45 +++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 752f7cb..d152ed3 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: @@ -31,18 +31,52 @@ jobs: - name: Build run: npm run build --if-present - # This step differs from the main CI. - - name: Compress the artifacts + - name: Compress the artifact run: zip -r ${{ env.ARTIFACT_NAME }} dist - # This step differs from the main CI. - - name: Upload artifacts + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + + upload-artifacts: + runs-on: ubuntu-latest + needs: build-ui + + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + + - name: Upload artifacts to tag uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ env.ARTIFACT_NAME }} asset_name: ${{ env.ARTIFACT_NAME }} tag: ${{ github.ref }} + + build-container: + runs-on: ubuntu-latest + needs: build-ui + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + Dockerfile + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + + - name: Extract artifacts + run: unzip ${{ env.ARTIFACT_NAME }} -d dist - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -54,7 +88,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # This step differs from the main CI. - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 From 339eb264d7149417fa49f1ae0baf2c97105715fa Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:49:07 +0200 Subject: [PATCH 16/41] Fix job naming in push-tag.yml --- .github/workflows/push-tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index d152ed3..c7e7951 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -15,7 +15,7 @@ env: jobs: - build: + build-ui: runs-on: ubuntu-latest steps: From 3a56200a4423b816ea62543854a6aa67985cae64 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 11:53:36 +0200 Subject: [PATCH 17/41] Attempt to fix unzipping artifact by omitting path --- .github/workflows/push-tag.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index c7e7951..dbd0f36 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -73,7 +73,6 @@ jobs: uses: actions/download-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} - path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} - name: Extract artifacts run: unzip ${{ env.ARTIFACT_NAME }} -d dist From f49b7371cdb492606384004de6b89b6f488d7c5c Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:02:56 +0200 Subject: [PATCH 18/41] Update all CI to use multiple stages --- .github/workflows/ci-master.yml | 38 +++++++++++++-- .github/workflows/push-release.yml | 76 ++++++++++++++++++++++++++---- .github/workflows/push-tag.yml | 11 ++--- 3 files changed, 107 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 628b806..fda6813 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -2,6 +2,7 @@ on: push: branches: - master + - develop pull_request: branches: - master @@ -18,11 +19,11 @@ env: jobs: - build: + build-ui: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: @@ -33,6 +34,34 @@ jobs: - name: Build run: npm run build --if-present + + - name: Compress the artifact + run: zip -r ${{ env.ARTIFACT_NAME }} dist + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + + build-container: + runs-on: ubuntu-latest + needs: build-ui + if: github.event_name != 'pull_request' + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + Dockerfile + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + + - name: Extract artifacts + run: unzip ${{ env.ARTIFACT_NAME }} -d dist - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -44,6 +73,9 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # - Tag as 'master' when master branch is pushed + # - Tag as pr-{n} when a PR is created + # - - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 @@ -58,6 +90,6 @@ jobs: uses: docker/build-push-action@v5 with: context: . - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/push-release.yml b/.github/workflows/push-release.yml index 0b9db53..19ef64d 100644 --- a/.github/workflows/push-release.yml +++ b/.github/workflows/push-release.yml @@ -1,17 +1,25 @@ on: - release: - types: [published] + push: + tags: + - 'v*' -name: push-release +name: push-tag + +# REGISTRY and IMAGE_NAME are for building and tagging the container. +# TARGET_ENV is used by Webpack to determine the build target. +env: + REGISTRY: ghcr.io + ARTIFACT_NAME: shocklink-webui.zip + IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui + TARGET_ENV: production jobs: - # Copied verbatim from https://docs.platformio.org/en/stable/integration/ci/github-actions.html - build: + build-ui: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-node@v3 with: @@ -22,6 +30,51 @@ jobs: - name: Build run: npm run build --if-present + + - name: Compress internal artifacts + run: zip -r ${{ env.ARTIFACT_NAME }} dist + + - name: Upload internal artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + + publish-artifacts: + runs-on: ubuntu-latest + needs: build-ui + + steps: + - name: Download internal artifact + uses: actions/download-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + + - name: Publish artifacts + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ env.ARTIFACT_NAME }} + asset_name: ${{ env.ARTIFACT_NAME }} + tag: ${{ github.ref }} + + build-container: + runs-on: ubuntu-latest + needs: build-ui + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + Dockerfile + + - name: Download internal artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + + - name: Extract artifacts + run: unzip ${{ env.ARTIFACT_NAME }} -d dist - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -38,11 +91,16 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest + type=semver,pattern=v{{major}} + type=semver,pattern=v{{major.minor}} + type=semver,pattern={{version}} - - name: Build and push + - name: Build image uses: docker/build-push-action@v5 with: context: . push: true - tags: ${{ steps.meta.output.tags }} - labels: ${{ steps.meta.output.labels }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index dbd0f36..0c87132 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -31,25 +31,24 @@ jobs: - name: Build run: npm run build --if-present - - name: Compress the artifact + - name: Compress internal artifacts run: zip -r ${{ env.ARTIFACT_NAME }} dist - - name: Upload artifact + - name: Upload internal artifacts uses: actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} - upload-artifacts: + publish-artifacts: runs-on: ubuntu-latest needs: build-ui steps: - - name: Download artifacts + - name: Download internal artifacts uses: actions/download-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} - path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} - name: Upload artifacts to tag uses: svenstaro/upload-release-action@v2 @@ -69,7 +68,7 @@ jobs: sparse-checkout: | Dockerfile - - name: Download artifacts + - name: Download internal artifacts uses: actions/download-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} From 959ff4368adff31a5fe488d2d1460e40ee3cfcfd Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:04:21 +0200 Subject: [PATCH 19/41] Fix push-release.yml triggering on tags instead of releases --- .github/workflows/push-release.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push-release.yml b/.github/workflows/push-release.yml index 19ef64d..25f4ceb 100644 --- a/.github/workflows/push-release.yml +++ b/.github/workflows/push-release.yml @@ -1,9 +1,8 @@ on: - push: - tags: - - 'v*' + release: + types: [published] -name: push-tag +name: push-release # REGISTRY and IMAGE_NAME are for building and tagging the container. # TARGET_ENV is used by Webpack to determine the build target. From 33a6d32f7cff8b3ae78f02d14058f16888251c6b Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:04:53 +0200 Subject: [PATCH 20/41] Fix ci-master.yml missing ARTIFACT_NAME variable --- .github/workflows/ci-master.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index fda6813..50911c9 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -14,6 +14,7 @@ name: ci-master # TARGET_ENV is used by Webpack to determine the build target. env: REGISTRY: ghcr.io + ARTIFACT_NAME: shocklink-webui.zip IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui TARGET_ENV: production From acdf1d2e6f860c323dfd0b52b8e81bac83fd280d Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:07:25 +0200 Subject: [PATCH 21/41] Update push-tag to only create prereleases --- .github/workflows/push-tag.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 0c87132..c5b84ab 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -57,6 +57,7 @@ jobs: file: ${{ env.ARTIFACT_NAME }} asset_name: ${{ env.ARTIFACT_NAME }} tag: ${{ github.ref }} + prerelease: true build-container: runs-on: ubuntu-latest From bd291d20f7166663fb05fc80b061dedceaf188cb Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:08:44 +0200 Subject: [PATCH 22/41] Set internal artifact retention to 1 day --- .github/workflows/ci-master.yml | 1 + .github/workflows/push-release.yml | 1 + .github/workflows/push-tag.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 50911c9..e9cd546 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -44,6 +44,7 @@ jobs: with: name: ${{ env.ARTIFACT_NAME }} path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + retention-days: 1 build-container: runs-on: ubuntu-latest diff --git a/.github/workflows/push-release.yml b/.github/workflows/push-release.yml index 25f4ceb..23f6e6a 100644 --- a/.github/workflows/push-release.yml +++ b/.github/workflows/push-release.yml @@ -38,6 +38,7 @@ jobs: with: name: ${{ env.ARTIFACT_NAME }} path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + retention-days: 1 publish-artifacts: runs-on: ubuntu-latest diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index c5b84ab..2de6cab 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -39,6 +39,7 @@ jobs: with: name: ${{ env.ARTIFACT_NAME }} path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + retention-days: 1 publish-artifacts: runs-on: ubuntu-latest From a6161584050b21d0bb9c10b9b1057fc151af9aca Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:11:22 +0200 Subject: [PATCH 23/41] Try to fix semver tagging --- .github/workflows/push-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-release.yml b/.github/workflows/push-release.yml index 23f6e6a..15a3648 100644 --- a/.github/workflows/push-release.yml +++ b/.github/workflows/push-release.yml @@ -93,9 +93,9 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=latest - type=semver,pattern=v{{major}} - type=semver,pattern=v{{major.minor}} type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} - name: Build image uses: docker/build-push-action@v5 From ba35f0eee649d46fdd07bc8f2f55a7f1965643ef Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:16:07 +0200 Subject: [PATCH 24/41] Use semver container tags for push-tag --- .github/workflows/push-tag.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 2de6cab..d773be9 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -94,7 +94,9 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} - name: Build image uses: docker/build-push-action@v5 From 59f3ef82e59d08e329e2210f1a9441f8c132cdca Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:20:39 +0200 Subject: [PATCH 25/41] Consolidate push-release workflow into push-tag --- .github/workflows/push-release.yml | 106 ----------------------------- .github/workflows/push-tag.yml | 5 +- 2 files changed, 3 insertions(+), 108 deletions(-) delete mode 100644 .github/workflows/push-release.yml diff --git a/.github/workflows/push-release.yml b/.github/workflows/push-release.yml deleted file mode 100644 index 15a3648..0000000 --- a/.github/workflows/push-release.yml +++ /dev/null @@ -1,106 +0,0 @@ -on: - release: - types: [published] - -name: push-release - -# REGISTRY and IMAGE_NAME are for building and tagging the container. -# TARGET_ENV is used by Webpack to determine the build target. -env: - REGISTRY: ghcr.io - ARTIFACT_NAME: shocklink-webui.zip - IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui - TARGET_ENV: production - -jobs: - - build-ui: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v3 - with: - node-version: 17.x - - - name: Install dependencies - run: npm ci - - - name: Build - run: npm run build --if-present - - - name: Compress internal artifacts - run: zip -r ${{ env.ARTIFACT_NAME }} dist - - - name: Upload internal artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ env.ARTIFACT_NAME }} - path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} - retention-days: 1 - - publish-artifacts: - runs-on: ubuntu-latest - needs: build-ui - - steps: - - name: Download internal artifact - uses: actions/download-artifact@v3 - with: - name: ${{ env.ARTIFACT_NAME }} - - - name: Publish artifacts - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ env.ARTIFACT_NAME }} - asset_name: ${{ env.ARTIFACT_NAME }} - tag: ${{ github.ref }} - - build-container: - runs-on: ubuntu-latest - needs: build-ui - - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - Dockerfile - - - name: Download internal artifacts - uses: actions/download-artifact@v3 - with: - name: ${{ env.ARTIFACT_NAME }} - - - name: Extract artifacts - run: unzip ${{ env.ARTIFACT_NAME }} -d dist - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to 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 }} - tags: | - type=raw,value=latest - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Build image - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index d773be9..88b9729 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -58,7 +58,6 @@ jobs: file: ${{ env.ARTIFACT_NAME }} asset_name: ${{ env.ARTIFACT_NAME }} tag: ${{ github.ref }} - prerelease: true build-container: runs-on: ubuntu-latest @@ -94,9 +93,11 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | + type=raw,value=latest + type=ref,event=tag type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} + type=semver,pattern={{major}} - name: Build image uses: docker/build-push-action@v5 From 21e99b2530157b10efdeb4bfc87385181972ade6 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:21:56 +0200 Subject: [PATCH 26/41] Disable major version zero tag --- .github/workflows/push-tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 88b9729..71aab00 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -97,7 +97,7 @@ jobs: type=ref,event=tag type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} + type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} - name: Build image uses: docker/build-push-action@v5 From 1adbed221c535dcf1048bf916893aa4d0a50b197 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 12:30:40 +0200 Subject: [PATCH 27/41] Enable build-container but don't push on PRs --- .github/workflows/ci-develop.yml | 95 ++++++++++++++++++++++++++++++++ .github/workflows/ci-master.yml | 4 +- 2 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci-develop.yml diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml new file mode 100644 index 0000000..dd19b67 --- /dev/null +++ b/.github/workflows/ci-develop.yml @@ -0,0 +1,95 @@ +on: + push: + branches: + - develop + pull_request: + branches: + - develop + types: [opened, reopened, synchronize] + +name: ci-develop + +# REGISTRY and IMAGE_NAME are for building and tagging the container. +# TARGET_ENV is used by Webpack to determine the build target. +env: + REGISTRY: ghcr.io + ARTIFACT_NAME: shocklink-webui.zip + IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui + TARGET_ENV: development + +jobs: + + build-ui: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v3 + with: + node-version: 17.x + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build --if-present + + - name: Compress the artifact + run: zip -r ${{ env.ARTIFACT_NAME }} dist + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ${{ github.workspace }}/${{ env.ARTIFACT_NAME }} + retention-days: 1 + + build-container: + runs-on: ubuntu-latest + needs: build-ui + + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + Dockerfile + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + + - name: Extract artifacts + run: unzip ${{ env.ARTIFACT_NAME }} -d dist + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # - Tag as 'master' when master branch is pushed + # - Tag as pr-{n} when a PR is created + # - + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value={{branch}},enable=${{ github.ref_name == 'develop' }} + type=ref,event=branch + type=ref,event=pr + + - name: Build image + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_Name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index e9cd546..811d359 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -2,7 +2,6 @@ on: push: branches: - master - - develop pull_request: branches: - master @@ -49,7 +48,6 @@ jobs: build-container: runs-on: ubuntu-latest needs: build-ui - if: github.event_name != 'pull_request' steps: - uses: actions/checkout@v4 @@ -92,6 +90,6 @@ jobs: uses: docker/build-push-action@v5 with: context: . - push: true + push: ${{ github.event_Name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 4ee93a9aee1ba5c5ca364e35c3bd090251c8d4b4 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 13:24:54 +0200 Subject: [PATCH 28/41] Add npm dependency caching --- .github/workflows/ci-develop.yml | 7 +++++++ .github/workflows/ci-master.yml | 7 +++++++ .github/workflows/push-tag.yml | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index dd19b67..369d3b6 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -28,6 +28,13 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 17.x + + - use: actions/cache@v3 + with: + path: | + ~/.npm + key: npm-${{ hashFiles('package-lock.json') }} + restore-keys: npm- - name: Install dependencies run: npm ci diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 811d359..9a156fd 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -29,6 +29,13 @@ jobs: with: node-version: 17.x + - use: actions/cache@v3 + with: + path: | + ~/.npm + key: npm-${{ hashFiles('package-lock.json') }} + restore-keys: npm- + - name: Install dependencies run: npm ci diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 71aab00..ec9bf8a 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -25,6 +25,13 @@ jobs: with: node-version: 17.x + - use: actions/cache@v3 + with: + path: | + ~/.npm + key: npm-${{ hashFiles('package-lock.json') }} + restore-keys: npm- + - name: Install dependencies run: npm ci From 003c38b8c10a349eb39435deff93babd5761d3b2 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 13:26:35 +0200 Subject: [PATCH 29/41] Fix use -> uses typo in CI --- .github/workflows/ci-develop.yml | 2 +- .github/workflows/ci-master.yml | 2 +- .github/workflows/push-tag.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 369d3b6..d6a2ccb 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -29,7 +29,7 @@ jobs: with: node-version: 17.x - - use: actions/cache@v3 + - uses: actions/cache@v3 with: path: | ~/.npm diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 9a156fd..0cdd24e 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -29,7 +29,7 @@ jobs: with: node-version: 17.x - - use: actions/cache@v3 + - uses: actions/cache@v3 with: path: | ~/.npm diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index ec9bf8a..b9909a3 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -25,7 +25,7 @@ jobs: with: node-version: 17.x - - use: actions/cache@v3 + - uses: actions/cache@v3 with: path: | ~/.npm From 5907d82bc4c290fdacaa0787ee614a271591d0d1 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 13:29:13 +0200 Subject: [PATCH 30/41] Add NODE_ENV environment variables to CI --- .github/workflows/ci-develop.yml | 1 + .github/workflows/ci-master.yml | 1 + .github/workflows/push-tag.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index d6a2ccb..6f15b30 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -16,6 +16,7 @@ env: ARTIFACT_NAME: shocklink-webui.zip IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui TARGET_ENV: development + NODE_ENV: development jobs: diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 0cdd24e..0cf2607 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -16,6 +16,7 @@ env: ARTIFACT_NAME: shocklink-webui.zip IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui TARGET_ENV: production + NODE_ENV: production jobs: diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index b9909a3..2572dc7 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -12,6 +12,7 @@ env: ARTIFACT_NAME: shocklink-webui.zip IMAGE_NAME: ${{ github.repository_owner }}/shocklink-webui TARGET_ENV: production + NODE_ENV: production jobs: From 7a6185193f0d39b98d16ea70d4ff95d786ff4e07 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 13:32:53 +0200 Subject: [PATCH 31/41] Force npm checkout to also get development dependencies --- .github/workflows/ci-develop.yml | 2 +- .github/workflows/ci-master.yml | 2 +- .github/workflows/push-tag.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 6f15b30..aa89037 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -38,7 +38,7 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm ci + run: npm install --development - name: Build run: npm run build --if-present diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 0cf2607..8f9cff7 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -38,7 +38,7 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm ci + run: npm install --development - name: Build run: npm run build --if-present diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 2572dc7..365d6de 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -34,7 +34,7 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm ci + run: npm install --development - name: Build run: npm run build --if-present From aead00a21aa179eb9e3107bfddf40fb6547458e6 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 13:51:45 +0200 Subject: [PATCH 32/41] Add node_modules to cache --- .github/workflows/ci-master.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 8f9cff7..bc7267f 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -34,6 +34,7 @@ jobs: with: path: | ~/.npm + ~/node_modules key: npm-${{ hashFiles('package-lock.json') }} restore-keys: npm- From a3e7458fd0750b8af11b9038e2e76a379b62cadd Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 13:55:22 +0200 Subject: [PATCH 33/41] Fix npm not installing dev dependencies in CI --- .github/workflows/ci-develop.yml | 2 +- .github/workflows/ci-master.yml | 2 +- .github/workflows/push-tag.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index aa89037..ea5a344 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -38,7 +38,7 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm install --development + run: npm install --save-dev - name: Build run: npm run build --if-present diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index bc7267f..7918b31 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -39,7 +39,7 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm install --development + run: npm install --save-dev - name: Build run: npm run build --if-present diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 365d6de..17f1c8f 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -34,7 +34,7 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm install --development + run: npm install --save-dev - name: Build run: npm run build --if-present From 9b7785c02e8d7ed8c0842f462f971ce688ac58a6 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 13:59:14 +0200 Subject: [PATCH 34/41] Fix NODE_ENV=production messing up npm install --- .github/workflows/ci-develop.yml | 2 +- .github/workflows/ci-master.yml | 4 +++- .github/workflows/push-tag.yml | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index ea5a344..3a4e381 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -38,7 +38,7 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm install --save-dev + run: npm install - name: Build run: npm run build --if-present diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 7918b31..14e81cf 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -39,7 +39,9 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm install --save-dev + run: npm install --production=false + # ^ + # This is necessary since NODE_ENV=production, but we need dev dependencies to build. - name: Build run: npm run build --if-present diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 17f1c8f..fdc5ac2 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -34,7 +34,9 @@ jobs: restore-keys: npm- - name: Install dependencies - run: npm install --save-dev + run: npm install --production=false + # ^ + # This is necessary since NODE_ENV=production, but we need dev dependencies to build. - name: Build run: npm run build --if-present From 1353530e914142774ecc1bbdfb5c72f3b0196166 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 14:06:18 +0200 Subject: [PATCH 35/41] Remove old incomplete comments --- .github/workflows/ci-develop.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 3a4e381..8dbbb41 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -81,9 +81,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # - Tag as 'master' when master branch is pushed - # - Tag as pr-{n} when a PR is created - # - - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 From 1cf36587fe7cef588ae14cfaa1b1c395277e8547 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 14:09:58 +0200 Subject: [PATCH 36/41] Fix capitalization in github.event_name reference --- .github/workflows/ci-develop.yml | 2 +- .github/workflows/ci-master.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 8dbbb41..769f7b9 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -95,6 +95,6 @@ jobs: uses: docker/build-push-action@v5 with: context: . - push: ${{ github.event_Name != 'pull_request' }} + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 14e81cf..3a70fa6 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -101,6 +101,6 @@ jobs: uses: docker/build-push-action@v5 with: context: . - push: ${{ github.event_Name != 'pull_request' }} + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From 5cb3da2ec3515e1e7d5ba9b3ec0895bcc3ab0bbc Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 14:10:47 +0200 Subject: [PATCH 37/41] Remove more partial comments --- .github/workflows/ci-master.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 3a70fa6..405728e 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -84,9 +84,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # - Tag as 'master' when master branch is pushed - # - Tag as pr-{n} when a PR is created - # - - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 From 80f62b15a25289ed7f3edb6eafee7414b2b3d736 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 14:38:36 +0200 Subject: [PATCH 38/41] Skip root directory when zipping artifacts --- .github/workflows/ci-develop.yml | 8 ++++---- .github/workflows/ci-master.yml | 8 ++++---- .github/workflows/push-tag.yml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index 769f7b9..a8e149b 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -43,10 +43,10 @@ jobs: - name: Build run: npm run build --if-present - - name: Compress the artifact - run: zip -r ${{ env.ARTIFACT_NAME }} dist + - name: Compress internal artifacts + run: cd dist && zip -r ${{ env.ARTIFACT_NAME }} . - - name: Upload artifact + - name: Upload internal artifacts uses: actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} @@ -63,7 +63,7 @@ jobs: sparse-checkout: | Dockerfile - - name: Download artifacts + - name: Download internal artifacts uses: actions/download-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index 405728e..d51e06a 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -46,10 +46,10 @@ jobs: - name: Build run: npm run build --if-present - - name: Compress the artifact - run: zip -r ${{ env.ARTIFACT_NAME }} dist + - name: Compress internal artifacts + run: cd dist && zip -r ${{ env.ARTIFACT_NAME }} . - - name: Upload artifact + - name: Upload internal artifacts uses: actions/upload-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} @@ -66,7 +66,7 @@ jobs: sparse-checkout: | Dockerfile - - name: Download artifacts + - name: Download internal artifacts uses: actions/download-artifact@v3 with: name: ${{ env.ARTIFACT_NAME }} diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index fdc5ac2..7b4cc8e 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -42,7 +42,7 @@ jobs: run: npm run build --if-present - name: Compress internal artifacts - run: zip -r ${{ env.ARTIFACT_NAME }} dist + run: cd dist && zip -r ${{ env.ARTIFACT_NAME }} . - name: Upload internal artifacts uses: actions/upload-artifact@v3 From 868c4439fefb65c51820b8d6612d2865a4d69226 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 14:41:21 +0200 Subject: [PATCH 39/41] Rename push-tag.yml to ci-tag.yml --- .github/workflows/{push-tag.yml => ci-tag.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{push-tag.yml => ci-tag.yml} (100%) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/ci-tag.yml similarity index 100% rename from .github/workflows/push-tag.yml rename to .github/workflows/ci-tag.yml From eb75d5dee1b772389e755b37f83d5e095d71654a Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 14:51:32 +0200 Subject: [PATCH 40/41] Fix internal artifact being located in wrong location --- .github/workflows/ci-develop.yml | 6 +++++- .github/workflows/ci-master.yml | 6 +++++- .github/workflows/ci-tag.yml | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-develop.yml b/.github/workflows/ci-develop.yml index a8e149b..6cda78b 100644 --- a/.github/workflows/ci-develop.yml +++ b/.github/workflows/ci-develop.yml @@ -44,7 +44,11 @@ jobs: run: npm run build --if-present - name: Compress internal artifacts - run: cd dist && zip -r ${{ env.ARTIFACT_NAME }} . + run: | + cd dist + zip -r ${{ env.ARTIFACT_NAME }} . + cd .. + mv dist/${{ env.ARTIFACT_NAME }} . - name: Upload internal artifacts uses: actions/upload-artifact@v3 diff --git a/.github/workflows/ci-master.yml b/.github/workflows/ci-master.yml index d51e06a..ef858bd 100644 --- a/.github/workflows/ci-master.yml +++ b/.github/workflows/ci-master.yml @@ -47,7 +47,11 @@ jobs: run: npm run build --if-present - name: Compress internal artifacts - run: cd dist && zip -r ${{ env.ARTIFACT_NAME }} . + run: | + cd dist + zip -r ${{ env.ARTIFACT_NAME }} . + cd .. + mv dist/${{ env.ARTIFACT_NAME }} . - name: Upload internal artifacts uses: actions/upload-artifact@v3 diff --git a/.github/workflows/ci-tag.yml b/.github/workflows/ci-tag.yml index 7b4cc8e..c9798fe 100644 --- a/.github/workflows/ci-tag.yml +++ b/.github/workflows/ci-tag.yml @@ -42,7 +42,11 @@ jobs: run: npm run build --if-present - name: Compress internal artifacts - run: cd dist && zip -r ${{ env.ARTIFACT_NAME }} . + run: | + cd dist + zip -r ${{ env.ARTIFACT_NAME }} . + cd .. + mv dist/${{ env.ARTIFACT_NAME }} . - name: Upload internal artifacts uses: actions/upload-artifact@v3 From b413b83c2ed71fdd52c83e1fb784117f2afb6116 Mon Sep 17 00:00:00 2001 From: Red Mushie Date: Tue, 19 Sep 2023 15:08:38 +0200 Subject: [PATCH 41/41] Rename push-tag workflow name to ci-tag --- .github/workflows/ci-tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-tag.yml b/.github/workflows/ci-tag.yml index c9798fe..196fc2c 100644 --- a/.github/workflows/ci-tag.yml +++ b/.github/workflows/ci-tag.yml @@ -3,7 +3,7 @@ on: tags: - 'v*' -name: push-tag +name: ci-tag # REGISTRY and IMAGE_NAME are for building and tagging the container. # TARGET_ENV is used by Webpack to determine the build target.