From 0459f2da441de02ab74137715364f5cc1d875801 Mon Sep 17 00:00:00 2001 From: Peter Sellars Date: Fri, 4 Oct 2024 21:13:32 +1300 Subject: [PATCH 1/5] chore(ci): pre-build and publish of DevContainer * Added build and push to GHCR capabilities * Provde a default `github.actor` for the `build` job in the `main.yml` workflow file. * Add `.dockerignore` file to exclude unnecessary files from the Docker build context. * Update syntax for act excludes in .dockerignore and .gitignore files. * Added a context to the build in the .devcontainer.json file. Closes: #4 --- .devcontainer/devcontainer.json | 3 ++- .dockerignore | 3 +++ .github/workflows/main.yml | 11 +++++++++-- .gitignore | 6 +++--- 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 .dockerignore diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b43246d..2ba51cb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,8 @@ { "name": "Catosplace Engineering Base Dev Container", "build": { - "dockerfile": "Dockerfile" + "dockerfile": "Dockerfile", + "context": ".devcontainer" }, "features": { "ghcr.io/devcontainers/features/node:1": { diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..036783c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +# act +*.env +*.secrets \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9cb3ff1..88ed131 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,14 @@ jobs: uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.actor || 'psellars' }} password: ${{ secrets.GITHUB_TOKEN }} - + + # Per-build the container image + - name: Pre-build the container image + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/catosplace-devcontainers/engineering-base + cacheFrom: ghcr.io/catosplace-devcontainers/engineering-base + push: always \ No newline at end of file diff --git a/.gitignore b/.gitignore index 408f4f3..a35ada3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ -# act environment file -.env -.secrets +# act +*.env +*.secrets # Dependency directories node_modules/ \ No newline at end of file From 076f4b1f11d78b5a91c8e75d073c427aa2514ff5 Mon Sep 17 00:00:00 2001 From: Peter Sellars Date: Sat, 5 Oct 2024 03:03:46 +0000 Subject: [PATCH 2/5] chore(ci): update devcontainer and dockerignore files * Remove the context from .devcontainer/devcontainer.json * Add a number of files to .dockerignore --- .devcontainer/devcontainer.json | 3 +-- .dockerignore | 17 ++++++++++++++++- .gitignore | 4 ++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2ba51cb..b43246d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,8 +1,7 @@ { "name": "Catosplace Engineering Base Dev Container", "build": { - "dockerfile": "Dockerfile", - "context": ".devcontainer" + "dockerfile": "Dockerfile" }, "features": { "ghcr.io/devcontainers/features/node:1": { diff --git a/.dockerignore b/.dockerignore index 036783c..940b043 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,18 @@ # act *.env -*.secrets \ No newline at end of file +*.secrets + +# git +.git +.gitattributes + +# commitlint +commitlint.config.js +.husky + +# Dependencies +node_modules +package*.json + +# Docs +*.md \ No newline at end of file diff --git a/.gitignore b/.gitignore index a35ada3..a72594c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ *.env *.secrets -# Dependency directories -node_modules/ \ No newline at end of file +# Dependencies +node_modules \ No newline at end of file From dfccaa398ca257984276b7872b82768c07586f73 Mon Sep 17 00:00:00 2001 From: Peter Sellars Date: Sat, 5 Oct 2024 03:12:20 +0000 Subject: [PATCH 3/5] chore(ci): add permissions for GITHUB_TOKEN * Provide the `packages: write` permission for GITHUB_TOKEN use. --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88ed131..46e06af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,9 @@ jobs: prebuild-devcontainer: runs-on: ubuntu-latest + permissions: + packages: write + steps: # Checkout the repository From e141ae1a4769f410f1888b60a679c64ebd985e32 Mon Sep 17 00:00:00 2001 From: Peter Sellars Date: Sat, 5 Oct 2024 03:17:14 +0000 Subject: [PATCH 4/5] chore(ci): update the default `github.actor` * Corrected this to the owner of the repository. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46e06af..7672bd2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: permissions: packages: write - + steps: # Checkout the repository @@ -29,7 +29,7 @@ jobs: uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ github.actor || 'psellars' }} + username: ${{ github.actor || 'petersellars' }} password: ${{ secrets.GITHUB_TOKEN }} # Per-build the container image From 19e21188ba22c6164322e374f1ee2c063574533a Mon Sep 17 00:00:00 2001 From: Peter Sellars Date: Sat, 5 Oct 2024 03:21:02 +0000 Subject: [PATCH 5/5] chore(ci): make package:write permission for workflow * Moved permissions from the job to the workflow. --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7672bd2..74e2b2d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,13 +7,13 @@ on: - main pull_request: +permissions: + packages: write + jobs: prebuild-devcontainer: runs-on: ubuntu-latest - permissions: - packages: write - steps: # Checkout the repository