From 5787cff1587106352c9f549fd66d6a15840a55db Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 17:36:01 -0500 Subject: [PATCH 001/101] fix: action + default values --- .github/pr-commenter.yml | 16 +++++++ .github/workflows/main.yaml | 71 +++++++++++++++++++++++++++++++ .github/workflows/pr-close.yaml | 25 +++++++++++ .github/workflows/pr-open.yaml | 54 +++++++++++++++++++++++ charts/example-hasura/values.yaml | 4 +- 5 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 .github/pr-commenter.yml create mode 100644 .github/workflows/main.yaml create mode 100644 .github/workflows/pr-close.yaml create mode 100644 .github/workflows/pr-open.yaml diff --git a/.github/pr-commenter.yml b/.github/pr-commenter.yml new file mode 100644 index 0000000..7b7e5a1 --- /dev/null +++ b/.github/pr-commenter.yml @@ -0,0 +1,16 @@ +comment: + header: | + Thank you for contributing to this repository :tada:. + + footer: | + --- + Automated comment created by [PR Commenter](https://github.com/exercism/pr-commenter-action) :robot:. + + snippets: + - id: any-markdown-file-changed + files: + - '*.md' + - '**/*.md' + body: | + It looks like you're changing a Markdown file. + Make sure your changes follow our [language guidelines](some-link) when writing documentation. diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..6094390 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,71 @@ +name: main +on: + push: + branches: + - main +jobs: + release: + runs-on: ubuntu-latest + + permissions: + packages: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + # used to run builders for architectures other than the host + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ github.repository }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: | + ghcr.io/${{ steps.meta.outputs.tags }} + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{ github.sha }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache + cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max + + # - name: Checkout prod + # uses: actions/checkout@v2 + # with: + # repository: ${{ secrets.GH_ORG }}/todo-prod + # persist-credentials: false + # fetch-depth: 0 + # - name: Update manifests + # run: | + # sleep 1 + # cat apps/${{ github.repo }}/overlays/staging/kustomization.yaml | sed -e "s@- cloudnativeentrepreneur/${{ github.repo }}:.*@- cloudnativeentrepreneur/${{ github.repo }}:${{ github.sha }}@g" | tee apps/${{ github.repo }}/overlays/staging/kustomization.yaml + # git config --global user.email "${{ secrets.GH_ORG }}@cloudnativeentrepreneur.com" + # git config --global user.name "${{ secrets.GH_ORG }}" + # git add . + # git commit -m "Promoting ${{ github.repo }} ${{ github.sha }}" + # - name: Push prod + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GH_TOKEN }} + # repository: ${{ secrets.GH_ORG }}/todo-prod + \ No newline at end of file diff --git a/.github/workflows/pr-close.yaml b/.github/workflows/pr-close.yaml new file mode 100644 index 0000000..a55ac07 --- /dev/null +++ b/.github/workflows/pr-close.yaml @@ -0,0 +1,25 @@ +name: pr +on: + pull_request: + types: [ closed ] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Setup Kube config + uses: azure/k8s-set-context@v3 + with: + method: kubeconfig + kubeconfig: ${{ secrets.KUBE_CONFIG }} + - name: Delete preview + run: | + # Install vCluster + curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; + sudo mv vcluster /usr/local/bin; + + # Delete the cluster + vcluster delete demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs diff --git a/.github/workflows/pr-open.yaml b/.github/workflows/pr-open.yaml new file mode 100644 index 0000000..82ce878 --- /dev/null +++ b/.github/workflows/pr-open.yaml @@ -0,0 +1,54 @@ +name: pr +on: + pull_request: + branches: + - main +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push container image + uses: docker/build-push-action@v3 + with: + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/demo-hasura:pr-${{ github.event.pull_request.number }} + - name: Setup Kube config + uses: azure/k8s-set-context@v3 + with: + method: kubeconfig + kubeconfig: ${{ secrets.KUBE_CONFIG }} + - name: Deploy preview + run: | + # Install vCluster + curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; + sudo mv vcluster /usr/local/bin; + + # Create a cluster + vcluster create demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs --expose + vcluster connect demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs + export KUBECONFIG=$PWD/kubeconfig.yaml + sleep 5 + kubectl get ingresses + + # Deploy + cd kustomize/overlays/preview + kustomize edit set image vfarcic/demo-hasura=${{ secrets.DOCKERHUB_USERNAME }}/demo-hasura:pr-${{ github.event.pull_request.number }} + kustomize build | kubectl apply --filename - + kubectl rollout status deployment demo-hasura + - name: Test + run: | + echo "I was to lazy to write tests" diff --git a/charts/example-hasura/values.yaml b/charts/example-hasura/values.yaml index 636ad6a..63ec49b 100755 --- a/charts/example-hasura/values.yaml +++ b/charts/example-hasura/values.yaml @@ -2,8 +2,8 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. image: - repository: draft - tag: dev + repository: ghcr.io/cloudnativeentrepreneur/example-hasura + tag: latest pullPolicy: IfNotPresent # define environment variables here as a map of key: value From dcbae2544ca3a0eeffdc55b61df5c5b449cf2cdf Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 17:38:26 -0500 Subject: [PATCH 002/101] fix: easier than making code harder to read by parsing and making lowercase --- .github/workflows/main.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6094390..cf316c7 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -34,7 +34,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ${{ github.repository }} + images: cloudnativeentrepreneur/example-hasura - name: Build and push Docker image uses: docker/build-push-action@v3 @@ -43,11 +43,11 @@ jobs: push: true tags: | ghcr.io/${{ steps.meta.outputs.tags }} - ghcr.io/${{ github.repository }}:latest - ghcr.io/${{ github.repository }}:${{ github.sha }} + ghcr.io/cloudnativeentrepreneur/example-hasura:latest + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache - cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max + cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache + cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max # - name: Checkout prod # uses: actions/checkout@v2 From f39c45498fbd619348da1b93712cac9f8027f84a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 17:50:31 -0500 Subject: [PATCH 003/101] fix: version --- .github/workflows/main.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index cf316c7..a0efaba 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -15,6 +15,7 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive + fetch-depth: 0 # used to run builders for architectures other than the host - name: Set up QEMU @@ -30,6 +31,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Application Version + id: version + uses: paulhatch/semantic-version@v4.0.2 + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v4 @@ -45,6 +50,7 @@ jobs: ghcr.io/${{ steps.meta.outputs.tags }} ghcr.io/cloudnativeentrepreneur/example-hasura:latest ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max From 0726d78c69e4d62a4565063113187f6b98232ca7 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 17:55:00 -0500 Subject: [PATCH 004/101] feat: semantic version --- .github/workflows/main.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a0efaba..e23dedb 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -34,6 +34,10 @@ jobs: - name: Application Version id: version uses: paulhatch/semantic-version@v4.0.2 + with: + major_pattern: "BREAKING CHANGE" + minor_pattern: "feat:" + - name: Extract metadata (tags, labels) for Docker id: meta @@ -51,6 +55,7 @@ jobs: ghcr.io/cloudnativeentrepreneur/example-hasura:latest ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version }} + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version_tag }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max From 686262bef5ab8a13521d7e2593ed2a3064332d81 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 17:58:48 -0500 Subject: [PATCH 005/101] feat: release --- .github/workflows/main.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e23dedb..26846a8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -38,6 +38,13 @@ jobs: major_pattern: "BREAKING CHANGE" minor_pattern: "feat:" + - uses: "marvinpinto/action-automatic-releases@1.2.1" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + automatic_release_tag: "${{ steps.version.outputs.version_tag }}" + prerelease: true + title: "${{ steps.version.outputs.version_tag }}" + - name: Extract metadata (tags, labels) for Docker id: meta From 1b5514478c4236cabe6b8870dde45296f2e27e18 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 17:59:27 -0500 Subject: [PATCH 006/101] feat: release --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 26846a8..6e15391 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -38,7 +38,7 @@ jobs: major_pattern: "BREAKING CHANGE" minor_pattern: "feat:" - - uses: "marvinpinto/action-automatic-releases@1.2.1" + - uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "${{ steps.version.outputs.version_tag }}" From 67bc7a953ab628c2187076fe7578d5e06058c024 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:05:31 -0500 Subject: [PATCH 007/101] feat: release --- .github/workflows/main.yaml | 9 +++------ .github/workflows/release.yaml | 0 2 files changed, 3 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6e15391..5a623a4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -38,13 +38,10 @@ jobs: major_pattern: "BREAKING CHANGE" minor_pattern: "feat:" - - uses: "marvinpinto/action-automatic-releases@latest" + - name: Release + uses: softprops/action-gh-release@v1 with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "${{ steps.version.outputs.version_tag }}" - prerelease: true - title: "${{ steps.version.outputs.version_tag }}" - + tag_name: "${{ steps.version.outputs.version_tag }}" - name: Extract metadata (tags, labels) for Docker id: meta diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..e69de29 From ddc5515441301dfd19807566e67de074386711d4 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:07:13 -0500 Subject: [PATCH 008/101] fix: token --- .github/workflows/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 5a623a4..d7a86d8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -42,6 +42,7 @@ jobs: uses: softprops/action-gh-release@v1 with: tag_name: "${{ steps.version.outputs.version_tag }}" + token: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta From 50771bfecde6434f4e8bdb4ec3a82ecf7b96acce Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:11:26 -0500 Subject: [PATCH 009/101] fix: tag and release --- .github/workflows/main.yaml | 25 ++++++++++++++++--------- .github/workflows/release.yaml | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d7a86d8..616b44f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -31,18 +31,25 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Application Version - id: version - uses: paulhatch/semantic-version@v4.0.2 + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.0 with: - major_pattern: "BREAKING CHANGE" - minor_pattern: "feat:" + github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Release - uses: softprops/action-gh-release@v1 + - name: Create a GitHub release + uses: ncipollo/release-action@v1 with: - tag_name: "${{ steps.version.outputs.version_tag }}" - token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.tag_version.outputs.new_tag }} + name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} + + # - name: Application Version + # id: version + # uses: paulhatch/semantic-version@v4.0.2 + # with: + # major_pattern: "BREAKING CHANGE" + # minor_pattern: "feat:" - name: Extract metadata (tags, labels) for Docker id: meta diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e69de29..32a5360 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -0,0 +1,15 @@ +name: Main + +on: + push: + tags: + - "v*.*.*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Release + uses: softprops/action-gh-release@v1 From 6ffb4a0b5fbeffadf8541b4cb16405486e22bb49 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:19:16 -0500 Subject: [PATCH 010/101] fix: create tag --- .github/workflows/main.yaml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 616b44f..fe06410 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -37,19 +37,23 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Create a GitHub release - uses: ncipollo/release-action@v1 + - name: Application Version + id: version + uses: paulhatch/semantic-version@v4.0.2 with: - tag: ${{ steps.tag_version.outputs.new_tag }} - name: Release ${{ steps.tag_version.outputs.new_tag }} - body: ${{ steps.tag_version.outputs.changelog }} + major_pattern: "BREAKING CHANGE" + minor_pattern: "feat:" - # - name: Application Version - # id: version - # uses: paulhatch/semantic-version@v4.0.2 - # with: - # major_pattern: "BREAKING CHANGE" - # minor_pattern: "feat:" + - name: Create tag + uses: actions/github-script@v5 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: "refs/tags/${ steps.version.output.version_tag }", + sha: context.sha + }) - name: Extract metadata (tags, labels) for Docker id: meta From cf9d29d38517ba1c99b8fa4bc12106b6d354039c Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:20:42 -0500 Subject: [PATCH 011/101] fix: version --- .github/workflows/main.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fe06410..f7e6281 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -31,11 +31,11 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Bump version and push tag - id: tag_version - uses: mathieudutour/github-tag-action@v6.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} + # - name: Bump version and push tag + # id: tag_version + # uses: mathieudutour/github-tag-action@v6.0 + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} - name: Application Version id: version @@ -45,7 +45,7 @@ jobs: minor_pattern: "feat:" - name: Create tag - uses: actions/github-script@v5 + uses: actions/github-script@v6 with: script: | github.rest.git.createRef({ From 63ed5d35e977907d9cfd50d2e08d746cd02ac936 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:21:53 -0500 Subject: [PATCH 012/101] fix: template string --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f7e6281..87c5eb7 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -51,7 +51,7 @@ jobs: github.rest.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, - ref: "refs/tags/${ steps.version.output.version_tag }", + ref: "refs/tags/${{ steps.version.output.version_tag }}", sha: context.sha }) From 6ee842040d978fbcf383477ff0c575ac27fdf31f Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:23:18 -0500 Subject: [PATCH 013/101] fix: outputS --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 87c5eb7..8ae0813 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -51,7 +51,7 @@ jobs: github.rest.git.createRef({ owner: context.repo.owner, repo: context.repo.repo, - ref: "refs/tags/${{ steps.version.output.version_tag }}", + ref: "refs/tags/${{ steps.version.outputs.version_tag }}", sha: context.sha }) From 0604ae1ad09c27cbd4fdd6348ca9e6f598768f15 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:28:05 -0500 Subject: [PATCH 014/101] fix: release docker image in release pipeline --- .github/workflows/main.yaml | 41 ---------------------------------- .github/workflows/release.yaml | 36 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8ae0813..0452feb 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -17,26 +17,6 @@ jobs: submodules: recursive fetch-depth: 0 - # used to run builders for architectures other than the host - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # - name: Bump version and push tag - # id: tag_version - # uses: mathieudutour/github-tag-action@v6.0 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - - name: Application Version id: version uses: paulhatch/semantic-version@v4.0.2 @@ -55,27 +35,6 @@ jobs: sha: context.sha }) - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: cloudnativeentrepreneur/example-hasura - - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: | - ghcr.io/${{ steps.meta.outputs.tags }} - ghcr.io/cloudnativeentrepreneur/example-hasura:latest - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version }} - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version_tag }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache - cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max - # - name: Checkout prod # uses: actions/checkout@v2 # with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 32a5360..dc9ccae 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,5 +11,41 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + + # used to run builders for architectures other than the host + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: cloudnativeentrepreneur/example-hasura + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: | + ghcr.io/${{ steps.meta.outputs.tags }} + ghcr.io/cloudnativeentrepreneur/example-hasura:latest + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version }} + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version_tag }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache + cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max + - name: Release uses: softprops/action-gh-release@v1 From 377319cd3e4cc8819f71eaedcd2a56923fbeb95a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:30:32 -0500 Subject: [PATCH 015/101] fix: workflow name --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index dc9ccae..35cdaf4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: Main +name: release on: push: From 2579858c6af8d7f3fcee2bbb8d683c9fef8ad54d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:39:30 -0500 Subject: [PATCH 016/101] fix: update version --- .github/workflows/main.yaml | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0452feb..477e1bf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -35,23 +35,18 @@ jobs: sha: context.sha }) - # - name: Checkout prod - # uses: actions/checkout@v2 - # with: - # repository: ${{ secrets.GH_ORG }}/todo-prod - # persist-credentials: false - # fetch-depth: 0 - # - name: Update manifests - # run: | - # sleep 1 - # cat apps/${{ github.repo }}/overlays/staging/kustomization.yaml | sed -e "s@- cloudnativeentrepreneur/${{ github.repo }}:.*@- cloudnativeentrepreneur/${{ github.repo }}:${{ github.sha }}@g" | tee apps/${{ github.repo }}/overlays/staging/kustomization.yaml - # git config --global user.email "${{ secrets.GH_ORG }}@cloudnativeentrepreneur.com" - # git config --global user.name "${{ secrets.GH_ORG }}" - # git add . - # git commit -m "Promoting ${{ github.repo }} ${{ github.sha }}" - # - name: Push prod - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GH_TOKEN }} - # repository: ${{ secrets.GH_ORG }}/todo-prod - \ No newline at end of file + - name: Update version in manifest + run: | + sleep 1 + cat charts/${{ github.repo }}/values.yaml | sed -e "s@- latest@- ${{ steps.version.outputs.version_tag }}@g" | tee charts/${{ github.repo }}/values.yaml + git config --global user.email "${{ secrets.GH_ORG }}@cloudnativeentrepreneur.com" + git config --global user.name "${{ secrets.GH_ORG }}" + git add . + git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" + + - name: Push prod + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GH_TOKEN }} + repository: ${{ github.repository }} + tags: true From 9c6edfb9d006578537c2ea4181bd91b83dc57c6f Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:40:17 -0500 Subject: [PATCH 017/101] fix: update version --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 477e1bf..6264d22 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -38,7 +38,7 @@ jobs: - name: Update version in manifest run: | sleep 1 - cat charts/${{ github.repo }}/values.yaml | sed -e "s@- latest@- ${{ steps.version.outputs.version_tag }}@g" | tee charts/${{ github.repo }}/values.yaml + cat charts/example-hasura/values.yaml | sed -e "s@- latest@- ${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml git config --global user.email "${{ secrets.GH_ORG }}@cloudnativeentrepreneur.com" git config --global user.name "${{ secrets.GH_ORG }}" git add . From 720d0bc0083d7981a0c13a86c27d6d09de4562bf Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:42:38 -0500 Subject: [PATCH 018/101] fix: update version --- .github/workflows/main.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6264d22..fe8577a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -39,8 +39,7 @@ jobs: run: | sleep 1 cat charts/example-hasura/values.yaml | sed -e "s@- latest@- ${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml - git config --global user.email "${{ secrets.GH_ORG }}@cloudnativeentrepreneur.com" - git config --global user.name "${{ secrets.GH_ORG }}" + git config --global user.name "${{ github.actor }}" git add . git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" From 596e56669c569d6eb2d4b859f99863b3de8a1dc4 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:44:34 -0500 Subject: [PATCH 019/101] fix: update version --- .github/workflows/main.yaml | 2 +- charts/example-hasura/values.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fe8577a..37885de 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -38,7 +38,7 @@ jobs: - name: Update version in manifest run: | sleep 1 - cat charts/example-hasura/values.yaml | sed -e "s@- latest@- ${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml + cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml git config --global user.name "${{ github.actor }}" git add . git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" diff --git a/charts/example-hasura/values.yaml b/charts/example-hasura/values.yaml index 63ec49b..b539067 100755 --- a/charts/example-hasura/values.yaml +++ b/charts/example-hasura/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. image: repository: ghcr.io/cloudnativeentrepreneur/example-hasura - tag: latest + tag: 0.0.1 pullPolicy: IfNotPresent # define environment variables here as a map of key: value From b7d1b8ca019ce268c179b8dc331badadf0246643 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:45:52 -0500 Subject: [PATCH 020/101] fix: update version --- charts/example-hasura/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/example-hasura/values.yaml b/charts/example-hasura/values.yaml index b539067..63ec49b 100755 --- a/charts/example-hasura/values.yaml +++ b/charts/example-hasura/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. image: repository: ghcr.io/cloudnativeentrepreneur/example-hasura - tag: 0.0.1 + tag: latest pullPolicy: IfNotPresent # define environment variables here as a map of key: value From 778cf5a2b9f3a72abf7001171cd98e37fda57fcf Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:49:50 -0500 Subject: [PATCH 021/101] fix: update version --- .github/workflows/main.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 37885de..c3a4326 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -43,9 +43,7 @@ jobs: git add . git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" - - name: Push prod - uses: ad-m/github-push-action@master + - uses: actions-ecosystem/action-push-tag@v1 with: - github_token: ${{ secrets.GH_TOKEN }} - repository: ${{ github.repository }} - tags: true + tag: ${{ steps.version.outputs.version_tag }} + message: '${{ steps.version.outputs.version_tag }}' \ No newline at end of file From 32391acd094eac817527c5ba5858bfa57fae71de Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:52:42 -0500 Subject: [PATCH 022/101] fix: push --- .github/workflows/main.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c3a4326..d7dcf7a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -42,8 +42,4 @@ jobs: git config --global user.name "${{ github.actor }}" git add . git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" - - - uses: actions-ecosystem/action-push-tag@v1 - with: - tag: ${{ steps.version.outputs.version_tag }} - message: '${{ steps.version.outputs.version_tag }}' \ No newline at end of file + git push origin ${{ steps.version.outputs.version_tag }} From ce3a0140491e5ad564be2db94988a8ea8698a710 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:55:07 -0500 Subject: [PATCH 023/101] fix: push --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d7dcf7a..4f67ac5 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -42,4 +42,4 @@ jobs: git config --global user.name "${{ github.actor }}" git add . git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" - git push origin ${{ steps.version.outputs.version_tag }} + git push --tags From 5f079639007dc01e7f48ff3cbb50ed9df745959e Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:58:28 -0500 Subject: [PATCH 024/101] fix: push --- .github/workflows/main.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4f67ac5..91ef37c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -42,4 +42,8 @@ jobs: git config --global user.name "${{ github.actor }}" git add . git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" - git push --tags + + - name: Push changes + uses: ad-m/github-push-action@master + with: + branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file From 5cb91f2c2506f74e2a7ebc3c7c9de50e24e59644 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 18:59:07 -0500 Subject: [PATCH 025/101] fix: push --- .github/workflows/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 91ef37c..a55aae1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -46,4 +46,5 @@ jobs: - name: Push changes uses: ad-m/github-push-action@master with: + github_token: ${{ secrets.GH_TOKEN }} branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file From d2daeba58a60d1212f18f1e0609f147854e34bd2 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:02:51 -0500 Subject: [PATCH 026/101] fix: push --- .github/workflows/main.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a55aae1..d786fc2 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -14,7 +14,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - submodules: recursive + persist-credentials: false fetch-depth: 0 - name: Application Version @@ -39,8 +39,9 @@ jobs: run: | sleep 1 cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml - git config --global user.name "${{ github.actor }}" - git add . + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add -A git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" - name: Push changes From 1d1da4f6924eaadab6fab1d536ab5605b96eda2d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:04:32 -0500 Subject: [PATCH 027/101] fix: push --- .github/workflows/main.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d786fc2..4d0c303 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -37,12 +37,13 @@ jobs: - name: Update version in manifest run: | - sleep 1 cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml + + - name: Commit changes + run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" - git add -A - git commit -m "chore: set version to ${{ steps.version.outputs.version_tag }}" + git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" - name: Push changes uses: ad-m/github-push-action@master From 4a93cae205e8cca46241b821d14b267d99dee48a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:07:48 -0500 Subject: [PATCH 028/101] fix: secret name --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4d0c303..ab7db46 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -41,12 +41,12 @@ jobs: - name: Commit changes run: | - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" - name: Push changes uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.GH_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file From ef70cf64e8fab9f0743b416d8bce7823f478b71f Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:12:06 -0500 Subject: [PATCH 029/101] fix: permissions --- .github/workflows/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ab7db46..b9e51ec 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -9,6 +9,7 @@ jobs: permissions: packages: write + contents: write steps: - name: Checkout From e24a2a07d07665fd379657d3dd6f92c490cf1bb1 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:13:24 -0500 Subject: [PATCH 030/101] fix: order --- .github/workflows/main.yaml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b9e51ec..4b28f70 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -25,6 +25,16 @@ jobs: major_pattern: "BREAKING CHANGE" minor_pattern: "feat:" + - name: Update version in manifest + run: | + cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml + + - name: Commit changes + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" + - name: Create tag uses: actions/github-script@v6 with: @@ -36,18 +46,10 @@ jobs: sha: context.sha }) - - name: Update version in manifest - run: | - cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml - - - name: Commit changes - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" + - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file From e0c9803ae8b5c3f1a12e043ab491e8e667c19725 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:14:17 -0500 Subject: [PATCH 031/101] fix: order --- .github/workflows/main.yaml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4b28f70..95fa9e1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -46,10 +46,8 @@ jobs: sha: context.sha }) - - - # - name: Push changes - # uses: ad-m/github-push-action@master - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file From e66014460983de61e8d6bdc60aadcf9eb201bc9e Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:16:23 -0500 Subject: [PATCH 032/101] fix: tag --- .github/workflows/main.yaml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 95fa9e1..704c8d9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -34,17 +34,18 @@ jobs: git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" + git tag -a ${{ steps.version.outputs.version_tag }} -m "${{ steps.version.outputs.version_tag }}" - - name: Create tag - uses: actions/github-script@v6 - with: - script: | - github.rest.git.createRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: "refs/tags/${{ steps.version.outputs.version_tag }}", - sha: context.sha - }) + # - name: Create tag + # uses: actions/github-script@v6 + # with: + # script: | + # github.rest.git.createRef({ + # owner: context.repo.owner, + # repo: context.repo.repo, + # ref: "refs/tags/${{ steps.version.outputs.version_tag }}", + # sha: context.sha + # }) - name: Push changes uses: ad-m/github-push-action@master From 448203dd5bca9b187c369a4ff6e44f004399c845 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:17:46 -0500 Subject: [PATCH 033/101] fix: tags --- .github/workflows/main.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 704c8d9..a0cb952 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -51,4 +51,5 @@ jobs: uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ steps.version.outputs.version_tag }} \ No newline at end of file + branch: ${{ steps.version.outputs.version_tag }} + tags: true \ No newline at end of file From 97c3e2a19a151a7dacd0f5ffd0a6593d56f323b8 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:19:58 -0500 Subject: [PATCH 034/101] fix: tags 2 --- .github/workflows/main.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a0cb952..232c017 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -46,7 +46,6 @@ jobs: # ref: "refs/tags/${{ steps.version.outputs.version_tag }}", # sha: context.sha # }) - - name: Push changes uses: ad-m/github-push-action@master with: From f499551286c2a4fdb3c895a8a1c01781ea92728d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:21:10 -0500 Subject: [PATCH 035/101] feat: bump --- .github/workflows/main.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 232c017..6f7a363 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -35,7 +35,6 @@ jobs: git config --local user.name "github-actions[bot]" git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" git tag -a ${{ steps.version.outputs.version_tag }} -m "${{ steps.version.outputs.version_tag }}" - # - name: Create tag # uses: actions/github-script@v6 # with: @@ -50,5 +49,4 @@ jobs: uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ steps.version.outputs.version_tag }} tags: true \ No newline at end of file From 38e21a3c515be1862eabf4df8eb0301d6e8118a7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 22 Oct 2022 00:21:27 +0000 Subject: [PATCH 036/101] chore: set version to v0.3.0 --- charts/example-hasura/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/example-hasura/values.yaml b/charts/example-hasura/values.yaml index 63ec49b..b49c9c6 100755 --- a/charts/example-hasura/values.yaml +++ b/charts/example-hasura/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. image: repository: ghcr.io/cloudnativeentrepreneur/example-hasura - tag: latest + tag: v0.3.0 pullPolicy: IfNotPresent # define environment variables here as a map of key: value From 34eca865062e72774e8b63f1985336b48be4cab5 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:22:37 -0500 Subject: [PATCH 037/101] feat: readd push to branch tag name --- .github/workflows/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6f7a363..bf7f084 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -49,4 +49,5 @@ jobs: uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ steps.version.outputs.version_tag }} tags: true \ No newline at end of file From fb97117881c1cc235e3cee7bcbb02a75f7515b20 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 19:23:32 -0500 Subject: [PATCH 038/101] fix: revert change to tag in main --- charts/example-hasura/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/example-hasura/values.yaml b/charts/example-hasura/values.yaml index b49c9c6..63ec49b 100755 --- a/charts/example-hasura/values.yaml +++ b/charts/example-hasura/values.yaml @@ -3,7 +3,7 @@ # Declare variables to be passed into your templates. image: repository: ghcr.io/cloudnativeentrepreneur/example-hasura - tag: v0.3.0 + tag: latest pullPolicy: IfNotPresent # define environment variables here as a map of key: value From d9558ef5b1dd70332cbd071fbf27a06f704b13fc Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 20:02:50 -0500 Subject: [PATCH 039/101] fix: on push tags --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 35cdaf4..50a3704 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,7 +3,7 @@ name: release on: push: tags: - - "v*.*.*" + - "*" jobs: build: From 7b118a8b4bd31577bf1caccc647af9e071c5fe4d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 20:03:55 -0500 Subject: [PATCH 040/101] fix: patch --- .github/workflows/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bf7f084..6592aec 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -24,6 +24,7 @@ jobs: with: major_pattern: "BREAKING CHANGE" minor_pattern: "feat:" + bump_each_commit: true - name: Update version in manifest run: | From 1bfb047c000d248843949fe5ad8d9181348009a4 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 20:09:16 -0500 Subject: [PATCH 041/101] fix: job names --- .github/workflows/main.yaml | 2 +- .github/workflows/release.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6592aec..ee039fd 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,7 +4,7 @@ on: branches: - main jobs: - release: + main: runs-on: ubuntu-latest permissions: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 50a3704..7674bc6 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,10 +3,10 @@ name: release on: push: tags: - - "*" + - "*" jobs: - build: + release: runs-on: ubuntu-latest steps: - name: Checkout From 51670f1411c966f7c1e0fe78d376a43206c1813b Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 20:14:48 -0500 Subject: [PATCH 042/101] fix: release to ghcr --- .github/workflows/main.yaml | 39 ++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ee039fd..e3e0283 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -51,4 +51,41 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ steps.version.outputs.version_tag }} - tags: true \ No newline at end of file + tags: true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: cloudnativeentrepreneur/example-hasura + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: | + ghcr.io/${{ steps.meta.outputs.tags }} + ghcr.io/cloudnativeentrepreneur/example-hasura:latest + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version }} + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version_tag }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache + cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max + + - name: Release + uses: softprops/action-gh-release@v1 \ No newline at end of file From 293b39dc25af5755266e5b5c422d513f8aa6bb0a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 20:19:09 -0500 Subject: [PATCH 043/101] fix: release --- .github/workflows/main.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e3e0283..0f43343 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -88,4 +88,6 @@ jobs: cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max - name: Release - uses: softprops/action-gh-release@v1 \ No newline at end of file + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.version.outputs.version_tag }} \ No newline at end of file From 98a5f4e932378ab447a89d50b9181ccb0e3c2f48 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 20:21:26 -0500 Subject: [PATCH 044/101] fix: release notes --- .github/workflows/main.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 0f43343..39a035a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -90,4 +90,5 @@ jobs: - name: Release uses: softprops/action-gh-release@v1 with: - tag_name: ${{ steps.version.outputs.version_tag }} \ No newline at end of file + tag_name: ${{ steps.version.outputs.version_tag }} + generate_release_notes: true \ No newline at end of file From 803ac3c8dbfc132ba9a5cddfb824ebb9a1af13b2 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 21 Oct 2022 21:05:50 -0500 Subject: [PATCH 045/101] chore: cleanup --- .github/workflows/main.yaml | 12 ++------ .github/workflows/release.yaml | 51 ---------------------------------- 2 files changed, 2 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 39a035a..2695a69 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -4,6 +4,7 @@ on: branches: - main jobs: + main: runs-on: ubuntu-latest @@ -36,16 +37,7 @@ jobs: git config --local user.name "github-actions[bot]" git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" git tag -a ${{ steps.version.outputs.version_tag }} -m "${{ steps.version.outputs.version_tag }}" - # - name: Create tag - # uses: actions/github-script@v6 - # with: - # script: | - # github.rest.git.createRef({ - # owner: context.repo.owner, - # repo: context.repo.repo, - # ref: "refs/tags/${{ steps.version.outputs.version_tag }}", - # sha: context.sha - # }) + - name: Push changes uses: ad-m/github-push-action@master with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index 7674bc6..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: release - -on: - push: - tags: - - "*" - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - # used to run builders for architectures other than the host - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: cloudnativeentrepreneur/example-hasura - - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: | - ghcr.io/${{ steps.meta.outputs.tags }} - ghcr.io/cloudnativeentrepreneur/example-hasura:latest - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version }} - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version_tag }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache - cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max - - - name: Release - uses: softprops/action-gh-release@v1 From ca832d1c39db89c9453c7e57342275f284ff017d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 15:59:05 -0500 Subject: [PATCH 046/101] feat: promotion --- .github/workflows/main.yaml | 21 ++++++++++++++++++- .../templates/hasura-migrations-job.yaml | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2695a69..09f9785 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -83,4 +83,23 @@ jobs: uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.version.outputs.version_tag }} - generate_release_notes: true \ No newline at end of file + generate_release_notes: true + + - name: Checkout production environment + uses: actions/checkout@v2 + with: + repository: cloudnativeentrepreneur/example-prod-env + persist-credentials: false + fetch-depth: 0 + + - name: Update prod environment + run: | + sleep 1 + yq -i '.spec.source.targetRevision = "${{ steps.version.outputs.version_tag }}"' helm/templates/example-hasura.yaml + git add . + git commit -m "Promoting example-hasura to ${{ steps.version.outputs.version_tag }}" + - name: Push prod + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + repository: cloudnativeentrepreneur/example-prod-env \ No newline at end of file diff --git a/charts/example-hasura/templates/hasura-migrations-job.yaml b/charts/example-hasura/templates/hasura-migrations-job.yaml index c9ba937..d25d3ea 100644 --- a/charts/example-hasura/templates/hasura-migrations-job.yaml +++ b/charts/example-hasura/templates/hasura-migrations-job.yaml @@ -4,7 +4,7 @@ kind: Job metadata: name: {{ .Values.service.name }}-migrations-{{ lower .Values.image.tag | replace "_" "-" }} labels: - chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + chart: {{ .Values.service.name }}-{{ lower .Values.image.tag | replace "_" "-" }} spec: template: metadata: From 0f7f87819047de7b3320133d676bc2318b419c68 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:05:09 -0500 Subject: [PATCH 047/101] fix: promotion --- .github/workflows/main.yaml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 09f9785..9591e9a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -88,16 +88,20 @@ jobs: - name: Checkout production environment uses: actions/checkout@v2 with: - repository: cloudnativeentrepreneur/example-prod-env + repository: CloudNativeEntrepreneur/example-prod-env persist-credentials: false fetch-depth: 0 - name: Update prod environment - run: | - sleep 1 - yq -i '.spec.source.targetRevision = "${{ steps.version.outputs.version_tag }}"' helm/templates/example-hasura.yaml + uses: mikefarah/yq@master + with: + cmd: yq -i '.spec.source.targetRevision = "${{ steps.version.outputs.version_tag }}"' helm/templates/example-hasura.yaml + + - name: Commit Prod Env Changes + run: | git add . - git commit -m "Promoting example-hasura to ${{ steps.version.outputs.version_tag }}" + git commit -m "feat: Promoting example-hasura to ${{ steps.version.outputs.version_tag }}" + - name: Push prod uses: ad-m/github-push-action@master with: From 9c66cb43a5a8fb016f9eab43b6896a6bab94311d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:07:18 -0500 Subject: [PATCH 048/101] fix: checkout@v3 --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9591e9a..dcbbc55 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -86,7 +86,7 @@ jobs: generate_release_notes: true - name: Checkout production environment - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: CloudNativeEntrepreneur/example-prod-env persist-credentials: false From 8573d1cfaab1a4e33014c2d8276d9c597e2b1f99 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:09:34 -0500 Subject: [PATCH 049/101] fix: ref --- .github/workflows/main.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index dcbbc55..c419cc2 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -91,6 +91,7 @@ jobs: repository: CloudNativeEntrepreneur/example-prod-env persist-credentials: false fetch-depth: 0 + ref: main - name: Update prod environment uses: mikefarah/yq@master From e507a0fd5dc5640c3b0f5a254662d4f30f2afcfb Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:13:13 -0500 Subject: [PATCH 050/101] fix: ref --- .github/workflows/main.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index c419cc2..dcbbc55 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -91,7 +91,6 @@ jobs: repository: CloudNativeEntrepreneur/example-prod-env persist-credentials: false fetch-depth: 0 - ref: main - name: Update prod environment uses: mikefarah/yq@master From 8c3f46a5c27c625fcbec44c90a4f04a4957ad587 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:15:05 -0500 Subject: [PATCH 051/101] fix: git user --- .github/workflows/main.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index dcbbc55..3ed402f 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -98,7 +98,9 @@ jobs: cmd: yq -i '.spec.source.targetRevision = "${{ steps.version.outputs.version_tag }}"' helm/templates/example-hasura.yaml - name: Commit Prod Env Changes - run: | + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" git add . git commit -m "feat: Promoting example-hasura to ${{ steps.version.outputs.version_tag }}" From 29c972be076f83360f5a0ac4f0c01cef4a8b5cfd Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:26:53 -0500 Subject: [PATCH 052/101] fix: PAT token --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 3ed402f..bf7b9c0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -107,5 +107,5 @@ jobs: - name: Push prod uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.GH_TOKEN }} repository: cloudnativeentrepreneur/example-prod-env \ No newline at end of file From 6f12946d4e983fdf003fb235416cb734166a94ee Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:30:11 -0500 Subject: [PATCH 053/101] fix: PAT token 2 --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bf7b9c0..ccd886c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -108,4 +108,4 @@ jobs: uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GH_TOKEN }} - repository: cloudnativeentrepreneur/example-prod-env \ No newline at end of file + repository: cloudnativeentrepreneur/example-prod-env From b620b9caf140ec6b1a35177427a36e20f5543e1a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 16:47:15 -0500 Subject: [PATCH 054/101] fix: port protocol --- charts/example-hasura/templates/ksvc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/example-hasura/templates/ksvc.yaml b/charts/example-hasura/templates/ksvc.yaml index 34cdcef..8ba49a2 100644 --- a/charts/example-hasura/templates/ksvc.yaml +++ b/charts/example-hasura/templates/ksvc.yaml @@ -20,6 +20,7 @@ spec: - image: hasura/graphql-engine:v2.0.10 ports: - containerPort: {{ .Values.service.internalPort }} + protocol: TCP env: - name: METADATA_POSTGRES_USERNAME valueFrom: From 538a6e31949d66ace2462e78a7627b27268b1406 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:27:50 -0500 Subject: [PATCH 055/101] feat: jobs refactor --- .../{main.yaml => publish-and-promote.yaml} | 56 +++++-------------- .github/workflows/release.yaml | 46 +++++++++++++++ 2 files changed, 61 insertions(+), 41 deletions(-) rename .github/workflows/{main.yaml => publish-and-promote.yaml} (53%) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/publish-and-promote.yaml similarity index 53% rename from .github/workflows/main.yaml rename to .github/workflows/publish-and-promote.yaml index ccd886c..6cc801e 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -1,16 +1,15 @@ -name: main +name: publish-and-promote on: push: - branches: - - main + tags: + - v*.*.* jobs: - main: + publish: runs-on: ubuntu-latest permissions: packages: write - contents: write steps: - name: Checkout @@ -19,32 +18,6 @@ jobs: persist-credentials: false fetch-depth: 0 - - name: Application Version - id: version - uses: paulhatch/semantic-version@v4.0.2 - with: - major_pattern: "BREAKING CHANGE" - minor_pattern: "feat:" - bump_each_commit: true - - - name: Update version in manifest - run: | - cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml - - - name: Commit changes - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" - git tag -a ${{ steps.version.outputs.version_tag }} -m "${{ steps.version.outputs.version_tag }}" - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ steps.version.outputs.version_tag }} - tags: true - - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -73,18 +46,19 @@ jobs: ghcr.io/${{ steps.meta.outputs.tags }} ghcr.io/cloudnativeentrepreneur/example-hasura:latest ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version }} - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ steps.version.outputs.version_tag }} + ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.ref_name }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max - - name: Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ steps.version.outputs.version_tag }} - generate_release_notes: true + promote: + needs: publish + runs-on: ubuntu-latest + permissions: + contents: write + + steps: - name: Checkout production environment uses: actions/checkout@v3 with: @@ -95,17 +69,17 @@ jobs: - name: Update prod environment uses: mikefarah/yq@master with: - cmd: yq -i '.spec.source.targetRevision = "${{ steps.version.outputs.version_tag }}"' helm/templates/example-hasura.yaml + cmd: yq -i '.spec.source.targetRevision = "${{ github.ref_name }}"' helm/templates/example-hasura.yaml - name: Commit Prod Env Changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add . - git commit -m "feat: Promoting example-hasura to ${{ steps.version.outputs.version_tag }}" + git commit -m "feat: Promoting example-hasura to ${{ github.ref_name }}" - name: Push prod uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GH_TOKEN }} - repository: cloudnativeentrepreneur/example-prod-env + repository: cloudnativeentrepreneur/example-prod-env \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..e187ef0 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,46 @@ +name: main +on: + push: + branches: + - main +jobs: + + release: + runs-on: ubuntu-latest + + permissions: + packages: write + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Application Version + id: version + uses: paulhatch/semantic-version@v4.0.2 + with: + major_pattern: "BREAKING CHANGE" + minor_pattern: "feat:" + bump_each_commit: true + + - name: Update version in manifest + run: | + cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml + + - name: Commit changes + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" + git tag -a ${{ steps.version.outputs.version_tag }} -m "${{ steps.version.outputs.version_tag }}" + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GH_TOKEN }} + branch: ${{ steps.version.outputs.version_tag }} + tags: true From a61c7b6811fb83110145cc569598bf07ed61ac0a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:34:03 -0500 Subject: [PATCH 056/101] fix: use PAT --- .github/workflows/publish-and-promote.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 6cc801e..b9a90fe 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -29,7 +29,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.GH_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta From f9b4ee46b1133acb94d305731da84007f9db893d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:35:08 -0500 Subject: [PATCH 057/101] fix: rebase --- .github/workflows/publish-and-promote.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index b9a90fe..0a5a370 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -8,9 +8,6 @@ jobs: publish: runs-on: ubuntu-latest - permissions: - packages: write - steps: - name: Checkout uses: actions/checkout@v3 From 3a58f7d4c1393311d934423bad27959e5cff4625 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:46:08 -0500 Subject: [PATCH 058/101] fix: permissions --- .github/workflows/publish-and-promote.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 0a5a370..df45cb9 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -8,6 +8,10 @@ jobs: publish: runs-on: ubuntu-latest + permissions: + packages: write + contents: write + steps: - name: Checkout uses: actions/checkout@v3 From 31d89ab00cc067fa07d38ae63eb97dafcb5219ab Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:48:07 -0500 Subject: [PATCH 059/101] fix: use generated token --- .github/workflows/publish-and-promote.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index df45cb9..5646bff 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -30,7 +30,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta From f195de6212942020b9b78a1a8dea5735840bf5d3 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:50:01 -0500 Subject: [PATCH 060/101] fix: ref name only --- .github/workflows/publish-and-promote.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 5646bff..ac0e73e 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -46,7 +46,6 @@ jobs: tags: | ghcr.io/${{ steps.meta.outputs.tags }} ghcr.io/cloudnativeentrepreneur/example-hasura:latest - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.sha }} ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.ref_name }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache From 8509b1322a898e4113eb1d5813f5be20a06da9c6 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:52:17 -0500 Subject: [PATCH 061/101] fix: debug --- .github/workflows/publish-and-promote.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index ac0e73e..3dd4cf6 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -38,6 +38,11 @@ jobs: with: images: cloudnativeentrepreneur/example-hasura + - name: debug + run: | + echo "Tags:\n\n${{ steps.meta.outputs.tags }}\n\n" + echo "Ref Name:\n\n${{ github.ref_name }}\n\n" + - name: Build and push Docker image uses: docker/build-push-action@v3 with: From 3212b47220f030d9ae1a364cad35d2955a8fbcc8 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:55:51 -0500 Subject: [PATCH 062/101] fix: ghcr + release --- .github/workflows/publish-and-promote.yaml | 2 +- .github/workflows/release.yaml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 3dd4cf6..0613670 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -36,7 +36,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: cloudnativeentrepreneur/example-hasura + images: ghcr.io/cloudnativeentrepreneur/example-hasura - name: debug run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e187ef0..776fcbe 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -44,3 +44,9 @@ jobs: github_token: ${{ secrets.GH_TOKEN }} branch: ${{ steps.version.outputs.version_tag }} tags: true + + - name: Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.version.outputs.version_tag }} + generate_release_notes: true \ No newline at end of file From a39ef0caf9ab220744eeb7c454cfecb6c02247c0 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 17:57:36 -0500 Subject: [PATCH 063/101] fix: cleanup --- .github/workflows/publish-and-promote.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 0613670..087a492 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -38,11 +38,6 @@ jobs: with: images: ghcr.io/cloudnativeentrepreneur/example-hasura - - name: debug - run: | - echo "Tags:\n\n${{ steps.meta.outputs.tags }}\n\n" - echo "Ref Name:\n\n${{ github.ref_name }}\n\n" - - name: Build and push Docker image uses: docker/build-push-action@v3 with: @@ -50,8 +45,6 @@ jobs: push: true tags: | ghcr.io/${{ steps.meta.outputs.tags }} - ghcr.io/cloudnativeentrepreneur/example-hasura:latest - ghcr.io/cloudnativeentrepreneur/example-hasura:${{ github.ref_name }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max From 748a21c3da78cb6b08d254d15b182c3c49f961a7 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:01:23 -0500 Subject: [PATCH 064/101] refactor: user yq to change release image tag --- .github/workflows/release.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 776fcbe..05b50c2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -28,8 +28,13 @@ jobs: bump_each_commit: true - name: Update version in manifest - run: | - cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml + uses: mikefarah/yq@master + with: + cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' charts/example-hasura/values.yaml + + # - name: Update version in manifest + # run: | + # cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml - name: Commit changes run: | From 75f4c404227d7d045e37de4b48a555409eaa3131 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:05:17 -0500 Subject: [PATCH 065/101] chore: cleanup --- .github/workflows/release.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 05b50c2..1e5ef8f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,10 +32,6 @@ jobs: with: cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' charts/example-hasura/values.yaml - # - name: Update version in manifest - # run: | - # cat charts/example-hasura/values.yaml | sed -e "s@latest@${{ steps.version.outputs.version_tag }}@g" | tee charts/example-hasura/values.yaml - - name: Commit changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" From 65157cd51320a2c560d010ac22eb8043288f4771 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:12:16 -0500 Subject: [PATCH 066/101] chore: better changelog? --- .github/workflows/release.yaml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1e5ef8f..cb57d98 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -46,8 +46,19 @@ jobs: branch: ${{ steps.version.outputs.version_tag }} tags: true - - name: Release - uses: softprops/action-gh-release@v1 + - name: Build Changelog + id: changelog + uses: mikepenz/release-changelog-builder-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Release + uses: mikepenz/action-gh-release@latest #softprops/action-gh-release with: - tag_name: ${{ steps.version.outputs.version_tag }} - generate_release_notes: true \ No newline at end of file + body: ${{steps.changelog.outputs.changelog}} + + # - name: Release + # uses: softprops/action-gh-release@v1 + # with: + # tag_name: ${{ steps.version.outputs.version_tag }} + # generate_release_notes: true \ No newline at end of file From a97f9ade0a82b0f670a18032eb04f1bed1cb0b6e Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:12:57 -0500 Subject: [PATCH 067/101] chore: better changelog? --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cb57d98..83ffd86 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -53,7 +53,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create Release - uses: mikepenz/action-gh-release@latest #softprops/action-gh-release + uses: mikepenz/action-gh-release@v0.2.0-a03 #softprops/action-gh-release with: body: ${{steps.changelog.outputs.changelog}} From 056a444572c4539760206d66df9e12dcf64a1229 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:13:49 -0500 Subject: [PATCH 068/101] chore: better changelog? --- .github/workflows/release.yaml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 83ffd86..8492941 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -52,13 +52,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Release - uses: mikepenz/action-gh-release@v0.2.0-a03 #softprops/action-gh-release + - name: Release + uses: softprops/action-gh-release@v1 with: - body: ${{steps.changelog.outputs.changelog}} - - # - name: Release - # uses: softprops/action-gh-release@v1 - # with: - # tag_name: ${{ steps.version.outputs.version_tag }} - # generate_release_notes: true \ No newline at end of file + tag_name: ${{ steps.version.outputs.version_tag }} + generate_release_notes: true + body: ${{steps.changelog.outputs.changelog}} \ No newline at end of file From e853f1e2b2637167da90fe0813a987d6490bd96a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:17:59 -0500 Subject: [PATCH 069/101] chore: better changelog? --- .github/workflows/release.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8492941..f29b000 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,6 +32,10 @@ jobs: with: cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' charts/example-hasura/values.yaml + - uses: nuuday/github-changelog-action@v1.0.0 + with: + next_version: ${{ steps.version.outputs.version_tag }} + - name: Commit changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" From 86f9e88de766fa15578df4e3421d6b8d0a140125 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:20:51 -0500 Subject: [PATCH 070/101] chore: better changelog? --- .github/workflows/release.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f29b000..8492941 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,10 +32,6 @@ jobs: with: cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' charts/example-hasura/values.yaml - - uses: nuuday/github-changelog-action@v1.0.0 - with: - next_version: ${{ steps.version.outputs.version_tag }} - - name: Commit changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" From af5c52b49815b31fabf135d26a767478a1ff16e5 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:36:56 -0500 Subject: [PATCH 071/101] feat: pr-open workflow (#6) * feat: pr-open workflow * fix: double registry name * fix: comment out preview env stuff for now * fix: cleanup --- .github/pr-commenter.yml | 1 + .github/workflows/pr-close.yaml | 30 +++++++------ .github/workflows/pr-commenter.yaml | 12 +++++ .github/workflows/pr-open.yaml | 54 ---------------------- .github/workflows/pr.yaml | 70 +++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/pr-commenter.yaml delete mode 100644 .github/workflows/pr-open.yaml create mode 100644 .github/workflows/pr.yaml diff --git a/.github/pr-commenter.yml b/.github/pr-commenter.yml index 7b7e5a1..36d259d 100644 --- a/.github/pr-commenter.yml +++ b/.github/pr-commenter.yml @@ -1,4 +1,5 @@ comment: + on-update: recreate header: | Thank you for contributing to this repository :tada:. diff --git a/.github/workflows/pr-close.yaml b/.github/workflows/pr-close.yaml index a55ac07..85a4e22 100644 --- a/.github/workflows/pr-close.yaml +++ b/.github/workflows/pr-close.yaml @@ -1,25 +1,27 @@ -name: pr +name: pr-close on: pull_request: types: [ closed ] jobs: - build: + pr-close: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 with: submodules: recursive - - name: Setup Kube config - uses: azure/k8s-set-context@v3 - with: - method: kubeconfig - kubeconfig: ${{ secrets.KUBE_CONFIG }} - - name: Delete preview - run: | - # Install vCluster - curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; - sudo mv vcluster /usr/local/bin; - # Delete the cluster - vcluster delete demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs + # - name: Setup Kube config + # uses: azure/k8s-set-context@v3 + # with: + # method: kubeconfig + # kubeconfig: ${{ secrets.KUBE_CONFIG }} + + # - name: Delete preview + # run: | + # # Install vCluster + # curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; + # sudo mv vcluster /usr/local/bin; + + # # Delete the cluster + # vcluster delete demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs diff --git a/.github/workflows/pr-commenter.yaml b/.github/workflows/pr-commenter.yaml new file mode 100644 index 0000000..8b89511 --- /dev/null +++ b/.github/workflows/pr-commenter.yaml @@ -0,0 +1,12 @@ +name: "PR Commenter" +on: + - pull_request_target + +jobs: + pr-comment: + runs-on: ubuntu-latest + steps: + - uses: exercism/pr-commenter-action@v1.3.0 + with: + github-token: "${{ github.token }}" + config-file: ".github/pr-commenter.yml" \ No newline at end of file diff --git a/.github/workflows/pr-open.yaml b/.github/workflows/pr-open.yaml deleted file mode 100644 index 82ce878..0000000 --- a/.github/workflows/pr-open.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: pr -on: - pull_request: - branches: - - main -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push container image - uses: docker/build-push-action@v3 - with: - push: true - tags: | - ${{ secrets.DOCKERHUB_USERNAME }}/demo-hasura:pr-${{ github.event.pull_request.number }} - - name: Setup Kube config - uses: azure/k8s-set-context@v3 - with: - method: kubeconfig - kubeconfig: ${{ secrets.KUBE_CONFIG }} - - name: Deploy preview - run: | - # Install vCluster - curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; - sudo mv vcluster /usr/local/bin; - - # Create a cluster - vcluster create demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs --expose - vcluster connect demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs - export KUBECONFIG=$PWD/kubeconfig.yaml - sleep 5 - kubectl get ingresses - - # Deploy - cd kustomize/overlays/preview - kustomize edit set image vfarcic/demo-hasura=${{ secrets.DOCKERHUB_USERNAME }}/demo-hasura:pr-${{ github.event.pull_request.number }} - kustomize build | kubectl apply --filename - - kubectl rollout status deployment demo-hasura - - name: Test - run: | - echo "I was to lazy to write tests" diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..2d2aa89 --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,70 @@ +name: pr +on: + pull_request: + branches: + - main +jobs: + pr: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/cloudnativeentrepreneur/example-hasura + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: | + ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache + cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max + + # - name: Setup Kube config + # uses: azure/k8s-set-context@v3 + # with: + # method: kubeconfig + # kubeconfig: ${{ secrets.KUBE_CONFIG }} + + # - name: Deploy preview + # run: | + # # Install vCluster + # curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; + # sudo mv vcluster /usr/local/bin; + + # # Create a cluster + # vcluster create example-hasura-pr-${{ github.event.pull_request.number }} --namespace prs --expose + # vcluster connect example-hasura-pr-${{ github.event.pull_request.number }} --namespace prs + # export KUBECONFIG=$PWD/kubeconfig.yaml + # sleep 5 + # kubectl get ingresses + + # # Deploy + # cd kustomize/overlays/preview + # kustomize edit set image vfarcic/example-hasura=cloudnativeentrepreneur/example-hasura:pr-${{ github.event.pull_request.number }} + # kustomize build | kubectl apply --filename - + # kubectl rollout status deployment example-hasura + # - name: Test + # run: | + # echo "I was to lazy to write tests" From 3462f32c380f0c033d4739c713d024dac6dc39ab Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 18:53:45 -0500 Subject: [PATCH 072/101] feat: close pr (#7) --- .github/workflows/pr-close.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-close.yaml b/.github/workflows/pr-close.yaml index 85a4e22..d1b66c9 100644 --- a/.github/workflows/pr-close.yaml +++ b/.github/workflows/pr-close.yaml @@ -2,14 +2,19 @@ name: pr-close on: pull_request: types: [ closed ] + jobs: + pr-close: runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@v3 - with: - submodules: recursive + + - name: test + run: | + echo "Test" # - name: Setup Kube config # uses: azure/k8s-set-context@v3 From cdcd801c4554e6d842959c27667f21e922ebfa0d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Oct 2022 18:57:16 -0500 Subject: [PATCH 073/101] chore(deps): update paulhatch/semantic-version action to v4.0.3 (#4) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8492941..b2a2315 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,7 +21,7 @@ jobs: - name: Application Version id: version - uses: paulhatch/semantic-version@v4.0.2 + uses: paulhatch/semantic-version@v4.0.3 with: major_pattern: "BREAKING CHANGE" minor_pattern: "feat:" From faab4e1687a015194e281874567003be2e691c7f Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 19:01:09 -0500 Subject: [PATCH 074/101] fix: delete pr-commenter as its neat but not actually doing anything (#8) --- .github/pr-commenter.yml | 17 ----------------- .github/workflows/pr-commenter.yaml | 12 ------------ 2 files changed, 29 deletions(-) delete mode 100644 .github/pr-commenter.yml delete mode 100644 .github/workflows/pr-commenter.yaml diff --git a/.github/pr-commenter.yml b/.github/pr-commenter.yml deleted file mode 100644 index 36d259d..0000000 --- a/.github/pr-commenter.yml +++ /dev/null @@ -1,17 +0,0 @@ -comment: - on-update: recreate - header: | - Thank you for contributing to this repository :tada:. - - footer: | - --- - Automated comment created by [PR Commenter](https://github.com/exercism/pr-commenter-action) :robot:. - - snippets: - - id: any-markdown-file-changed - files: - - '*.md' - - '**/*.md' - body: | - It looks like you're changing a Markdown file. - Make sure your changes follow our [language guidelines](some-link) when writing documentation. diff --git a/.github/workflows/pr-commenter.yaml b/.github/workflows/pr-commenter.yaml deleted file mode 100644 index 8b89511..0000000 --- a/.github/workflows/pr-commenter.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: "PR Commenter" -on: - - pull_request_target - -jobs: - pr-comment: - runs-on: ubuntu-latest - steps: - - uses: exercism/pr-commenter-action@v1.3.0 - with: - github-token: "${{ github.token }}" - config-file: ".github/pr-commenter.yml" \ No newline at end of file From f0b3f7e7d5b398065c66521da812da6cc43e9af1 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 20:21:49 -0500 Subject: [PATCH 075/101] Refactor/dry pipeline (#9) * refactor: dry pipeline for easier sharing * refactor: downcase * refactor: downcase 2 * refactor: downcase 3 * refactor: env.REPO * refactor: cleanup * refactor: apply to other actions --- .github/workflows/pr-close.yaml | 5 +++++ .github/workflows/pr.yaml | 12 ++++++++---- .github/workflows/publish-and-promote.yaml | 15 +++++++++++---- .github/workflows/release.yaml | 9 ++++++++- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-close.yaml b/.github/workflows/pr-close.yaml index d1b66c9..0e6a3fb 100644 --- a/.github/workflows/pr-close.yaml +++ b/.github/workflows/pr-close.yaml @@ -9,6 +9,11 @@ jobs: runs-on: ubuntu-latest steps: + + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 2d2aa89..17b0bd6 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -8,6 +8,10 @@ jobs: runs-on: ubuntu-latest steps: + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + - name: Checkout uses: actions/checkout@v3 @@ -28,7 +32,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ghcr.io/cloudnativeentrepreneur/example-hasura + images: ghcr.io/${{ env.REPO }} - name: Build and push Docker image uses: docker/build-push-action@v3 @@ -38,8 +42,8 @@ jobs: tags: | ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache - cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max + cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max # - name: Setup Kube config # uses: azure/k8s-set-context@v3 @@ -62,7 +66,7 @@ jobs: # # Deploy # cd kustomize/overlays/preview - # kustomize edit set image vfarcic/example-hasura=cloudnativeentrepreneur/example-hasura:pr-${{ github.event.pull_request.number }} + # kustomize edit set image ${{ env.REPO }}=${{ env.REPO }}:pr-${{ github.event.pull_request.number }} # kustomize build | kubectl apply --filename - # kubectl rollout status deployment example-hasura # - name: Test diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 087a492..92a4909 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -13,6 +13,13 @@ jobs: contents: write steps: + + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + # - name: use REPO + # run: echo "The value of REPO is: ${{ env.REPO }}" + - name: Checkout uses: actions/checkout@v3 with: @@ -36,7 +43,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ghcr.io/cloudnativeentrepreneur/example-hasura + images: ghcr.io/${{ env.REPO }} - name: Build and push Docker image uses: docker/build-push-action@v3 @@ -46,8 +53,8 @@ jobs: tags: | ghcr.io/${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache - cache-to: type=registry,ref=ghcr.io/cloudnativeentrepreneur/example-hasura:buildcache,mode=max + cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache + cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max promote: needs: publish @@ -60,7 +67,7 @@ jobs: - name: Checkout production environment uses: actions/checkout@v3 with: - repository: CloudNativeEntrepreneur/example-prod-env + repository: cloudnativeentrepreneur/example-prod-env persist-credentials: false fetch-depth: 0 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b2a2315..d707ce0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -13,6 +13,13 @@ jobs: contents: write steps: + + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + # - name: use REPO + # run: echo "The value of REPO is: ${{ env.REPO }}" + - name: Checkout uses: actions/checkout@v3 with: @@ -30,7 +37,7 @@ jobs: - name: Update version in manifest uses: mikefarah/yq@master with: - cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' charts/example-hasura/values.yaml + cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' charts/${{ github.event.repository.name }}/values.yaml - name: Commit changes run: | From 03933e0624c1129f347f1d4d2c8085b0c6bf0d09 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 21:01:46 -0500 Subject: [PATCH 076/101] refactor: use org secret --- .github/workflows/publish-and-promote.yaml | 2 +- .github/workflows/release.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 92a4909..0f5fdca 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -86,5 +86,5 @@ jobs: - name: Push prod uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.GH_TOKEN }} + github_token: ${{ secrets.GH_ORG_TOKEN }} repository: cloudnativeentrepreneur/example-prod-env \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d707ce0..93b8f21 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -49,7 +49,7 @@ jobs: - name: Push changes uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.GH_TOKEN }} + github_token: ${{ secrets.GH_ORG_TOKEN }} branch: ${{ steps.version.outputs.version_tag }} tags: true From a8e4809f49068f54e4c19293f2f2066ab8d2ee1f Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sun, 23 Oct 2022 21:04:22 -0500 Subject: [PATCH 077/101] refactor: DRY - use repo name --- .github/workflows/publish-and-promote.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 0f5fdca..8f568a8 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -74,14 +74,14 @@ jobs: - name: Update prod environment uses: mikefarah/yq@master with: - cmd: yq -i '.spec.source.targetRevision = "${{ github.ref_name }}"' helm/templates/example-hasura.yaml + cmd: yq -i '.spec.source.targetRevision = "${{ github.ref_name }}"' helm/templates/${{ github.event.repository.name }}.yaml - name: Commit Prod Env Changes run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git add . - git commit -m "feat: Promoting example-hasura to ${{ github.ref_name }}" + git commit -m "feat: Promoting ${{ github.event.repository.name }} to ${{ github.ref_name }}" - name: Push prod uses: ad-m/github-push-action@master From 789d04cfc7d9346bd5812ab79a735851d8703d04 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 24 Oct 2022 14:05:24 -0500 Subject: [PATCH 078/101] feat: /helm + other gha improvements from other repo --- .dockerignore | 2 +- .github/workflows/pr.yaml | 30 ++++++++++-- .github/workflows/release.yaml | 43 +++++++++++++--- .lighthouse/jenkins-x/pullrequest.yaml | 42 ---------------- .lighthouse/jenkins-x/release.yaml | 49 ------------------- .lighthouse/jenkins-x/triggers.yaml | 17 ------- Makefile | 10 ++-- {charts/example-hasura => helm}/Chart.yaml | 0 {charts/example-hasura => helm}/README.md | 0 .../templates/_helpers.tpl | 0 .../templates/hasura-cli-role.yaml | 0 .../templates/hasura-cli-rolebinding.yaml | 0 .../templates/hasura-cli-sa.yaml | 0 .../templates/hasura-migrations-job.yaml | 0 .../templates/hasura-psql.yaml | 0 .../templates/ksvc.yaml | 0 .../templates/service.yaml | 0 {charts/example-hasura => helm}/values.yaml | 0 18 files changed, 68 insertions(+), 125 deletions(-) delete mode 100644 .lighthouse/jenkins-x/pullrequest.yaml delete mode 100644 .lighthouse/jenkins-x/release.yaml delete mode 100644 .lighthouse/jenkins-x/triggers.yaml rename {charts/example-hasura => helm}/Chart.yaml (100%) rename {charts/example-hasura => helm}/README.md (100%) rename {charts/example-hasura => helm}/templates/_helpers.tpl (100%) rename {charts/example-hasura => helm}/templates/hasura-cli-role.yaml (100%) rename {charts/example-hasura => helm}/templates/hasura-cli-rolebinding.yaml (100%) rename {charts/example-hasura => helm}/templates/hasura-cli-sa.yaml (100%) rename {charts/example-hasura => helm}/templates/hasura-migrations-job.yaml (100%) rename {charts/example-hasura => helm}/templates/hasura-psql.yaml (100%) rename {charts/example-hasura => helm}/templates/ksvc.yaml (100%) rename {charts/example-hasura => helm}/templates/service.yaml (100%) rename {charts/example-hasura => helm}/values.yaml (100%) diff --git a/.dockerignore b/.dockerignore index ebf1d3d..7e58ab2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1 @@ -charts +helm/ diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 17b0bd6..0beb8f8 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -1,10 +1,34 @@ name: pr + on: + pull_request: - branches: - - main + jobs: - pr: + + # quality: + # runs-on: ubuntu-latest + + # strategy: + # matrix: + # node-version: [18.x] + # # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + # steps: + # - uses: actions/checkout@v2 + # - name: Use Node.js ${{ matrix.node-version }} + # uses: actions/setup-node@v2 + # with: + # node-version: ${{ matrix.node-version }} + # cache: 'npm' + # - run: npm ci + # - run: npm run lint --if-present + # - run: npm run build --if-present + # - run: npm test + # - run: npx codecov + + preview: + needs: quality runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 93b8f21..0ef67ad 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,8 +5,30 @@ on: - main jobs: + # quality: + # runs-on: ubuntu-latest + + # strategy: + # matrix: + # node-version: [18.x] + # # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + # steps: + # - uses: actions/checkout@v2 + # - name: Use Node.js ${{ matrix.node-version }} + # uses: actions/setup-node@v2 + # with: + # node-version: ${{ matrix.node-version }} + # cache: 'npm' + # - run: npm ci + # - run: npm run lint --if-present + # - run: npm run build --if-present + # - run: npm test + # - run: npx codecov + release: runs-on: ubuntu-latest + # needs: quality permissions: packages: write @@ -34,10 +56,21 @@ jobs: minor_pattern: "feat:" bump_each_commit: true - - name: Update version in manifest + - name: Build Changelog + id: changelog + uses: mikepenz/release-changelog-builder-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Update version in helm values uses: mikefarah/yq@master with: - cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' charts/${{ github.event.repository.name }}/values.yaml + cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' helm/values.yaml + + - name: Update version in helm chart + uses: mikefarah/yq@master + with: + cmd: yq -i '.version = "${{ steps.version.outputs.version_tag }}"' helm/Chart.yaml - name: Commit changes run: | @@ -53,12 +86,6 @@ jobs: branch: ${{ steps.version.outputs.version_tag }} tags: true - - name: Build Changelog - id: changelog - uses: mikepenz/release-changelog-builder-action@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Release uses: softprops/action-gh-release@v1 with: diff --git a/.lighthouse/jenkins-x/pullrequest.yaml b/.lighthouse/jenkins-x/pullrequest.yaml deleted file mode 100644 index cfc526a..0000000 --- a/.lighthouse/jenkins-x/pullrequest.yaml +++ /dev/null @@ -1,42 +0,0 @@ -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - creationTimestamp: null - name: pullrequest -spec: - pipelineSpec: - tasks: - - name: from-build-pack - resources: {} - taskSpec: - metadata: - annotations: - sidecar.istio.io/inject: "false" - stepTemplate: - image: uses:jenkins-x/jx3-pipeline-catalog/tasks/docker-helm/pullrequest.yaml@versionStream - name: "" - resources: - requests: - cpu: 400m - memory: 512Mi - workingDir: /workspace/source - steps: - - image: uses:jenkins-x/jx3-pipeline-catalog/tasks/git-clone/git-clone-pr.yaml@versionStream - name: "" - resources: {} - - name: jx-variables - resources: {} - - name: build-container-build - resources: {} - - image: ghcr.io/jenkins-x-plugins/jx-preview:0.0.182 - name: promote-jx-preview - resources: {} - script: | - #!/usr/bin/env sh - source .jx/variables.sh - jx preview create - - podTemplate: {} - serviceAccountName: tekton-bot - timeout: 12h0m0s -status: {} diff --git a/.lighthouse/jenkins-x/release.yaml b/.lighthouse/jenkins-x/release.yaml deleted file mode 100644 index 68ddb84..0000000 --- a/.lighthouse/jenkins-x/release.yaml +++ /dev/null @@ -1,49 +0,0 @@ -apiVersion: tekton.dev/v1beta1 -kind: PipelineRun -metadata: - creationTimestamp: null - name: release -spec: - pipelineSpec: - tasks: - - name: from-build-pack - resources: {} - taskSpec: - metadata: - annotations: - sidecar.istio.io/inject: "false" - stepTemplate: - image: uses:jenkins-x/jx3-pipeline-catalog/tasks/javascript/release.yaml@versionStream - name: "" - resources: - requests: - cpu: 400m - memory: 512Mi - volumeMounts: - - mountPath: /tekton/home/npm - name: npmrc - workingDir: /workspace/source - steps: - - image: uses:jenkins-x/jx3-pipeline-catalog/tasks/git-clone/git-clone.yaml@versionStream - name: "" - resources: {} - - name: next-version - resources: {} - - name: jx-variables - resources: {} - - name: build-container-build - resources: {} - env: - - name: KANIKO_FLAGS - value: --snapshotMode=redo - - name: promote-changelog - resources: {} - - name: promote-helm-release - resources: {} - - name: promote-jx-promote - resources: {} - - podTemplate: {} - serviceAccountName: tekton-bot - timeout: 12h0m0s -status: {} diff --git a/.lighthouse/jenkins-x/triggers.yaml b/.lighthouse/jenkins-x/triggers.yaml deleted file mode 100644 index 95aba4d..0000000 --- a/.lighthouse/jenkins-x/triggers.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: config.lighthouse.jenkins-x.io/v1alpha1 -kind: TriggerConfig -spec: - presubmits: - - name: pr - context: "pr" - always_run: true - optional: false - source: "pullrequest.yaml" - postsubmits: - - name: release - context: "release" - source: "release.yaml" - ignore_changes: '^(\.lighthouse\/jenkins-x\/pullrequest\.yaml)|(preview\/.+)$' - branches: - - ^main$ - - ^master$ diff --git a/Makefile b/Makefile index 2245bee..48ddf0d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ HASURA_ENDPOINT?=http://example-hasura.default.127.0.0.1.sslip.io -LOCAL_DEV_CLUSTER ?= kind-local-dev-cluster +LOCAL_DEV_CLUSTER ?= rancher-desktop NOW := $(shell date +%m_%d_%Y_%H_%M) SERVICE_NAME := example-hasura HASURA_GRAPHQL_DATABASE_URL=postgres://readmodel:$(kubectl get secret readmodel.example-readmodel-postgresql.credentials.postgresql.acid.zalan.do)@readmodel.default.cluster.svc.local:5432/readmodel @@ -26,16 +26,16 @@ load-local-image-to-kind: deploy-to-local-cluster: kubectl ctx $(LOCAL_DEV_CLUSTER) - helm template ./charts/$(SERVICE_NAME)/ \ - -f ./charts/$(SERVICE_NAME)/values.yaml \ + helm template helm/ \ + -f helm/values.yaml \ --set image.repository=dev.local/$(SERVICE_NAME),image.tag=$(NOW) \ | kubectl apply -f - kubectl wait --for=condition=ready ksvc example-hasura --timeout=600s delete-local-deployment: kubectl ctx $(LOCAL_DEV_CLUSTER) - helm template ./charts/$(SERVICE_NAME)/ \ - -f ./charts/$(SERVICE_NAME)/values.yaml \ + helm template helm/ \ + -f helm/values.yaml \ --set image.repository=dev.local/$(SERVICE_NAME),image.tag=$(NOW) \ | kubectl delete -f - diff --git a/charts/example-hasura/Chart.yaml b/helm/Chart.yaml similarity index 100% rename from charts/example-hasura/Chart.yaml rename to helm/Chart.yaml diff --git a/charts/example-hasura/README.md b/helm/README.md similarity index 100% rename from charts/example-hasura/README.md rename to helm/README.md diff --git a/charts/example-hasura/templates/_helpers.tpl b/helm/templates/_helpers.tpl similarity index 100% rename from charts/example-hasura/templates/_helpers.tpl rename to helm/templates/_helpers.tpl diff --git a/charts/example-hasura/templates/hasura-cli-role.yaml b/helm/templates/hasura-cli-role.yaml similarity index 100% rename from charts/example-hasura/templates/hasura-cli-role.yaml rename to helm/templates/hasura-cli-role.yaml diff --git a/charts/example-hasura/templates/hasura-cli-rolebinding.yaml b/helm/templates/hasura-cli-rolebinding.yaml similarity index 100% rename from charts/example-hasura/templates/hasura-cli-rolebinding.yaml rename to helm/templates/hasura-cli-rolebinding.yaml diff --git a/charts/example-hasura/templates/hasura-cli-sa.yaml b/helm/templates/hasura-cli-sa.yaml similarity index 100% rename from charts/example-hasura/templates/hasura-cli-sa.yaml rename to helm/templates/hasura-cli-sa.yaml diff --git a/charts/example-hasura/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml similarity index 100% rename from charts/example-hasura/templates/hasura-migrations-job.yaml rename to helm/templates/hasura-migrations-job.yaml diff --git a/charts/example-hasura/templates/hasura-psql.yaml b/helm/templates/hasura-psql.yaml similarity index 100% rename from charts/example-hasura/templates/hasura-psql.yaml rename to helm/templates/hasura-psql.yaml diff --git a/charts/example-hasura/templates/ksvc.yaml b/helm/templates/ksvc.yaml similarity index 100% rename from charts/example-hasura/templates/ksvc.yaml rename to helm/templates/ksvc.yaml diff --git a/charts/example-hasura/templates/service.yaml b/helm/templates/service.yaml similarity index 100% rename from charts/example-hasura/templates/service.yaml rename to helm/templates/service.yaml diff --git a/charts/example-hasura/values.yaml b/helm/values.yaml similarity index 100% rename from charts/example-hasura/values.yaml rename to helm/values.yaml From b51f54d86a25067d3cc732c6cc618365dbb26493 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:49:51 -0500 Subject: [PATCH 079/101] chore(deps): update postgres docker tag to v15 (#5) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- docker-compose.default-example.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.default-example.yaml b/docker-compose.default-example.yaml index f6fc37e..e201807 100644 --- a/docker-compose.default-example.yaml +++ b/docker-compose.default-example.yaml @@ -1,7 +1,7 @@ version: '3.6' services: postgres: - image: postgres:12 + image: postgres:15 restart: always volumes: - db_data:/var/lib/postgresql/data From 60e5598abf3bb557259a68c335ca055877cefc82 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 24 Oct 2022 20:56:18 -0500 Subject: [PATCH 080/101] fix: kubectl version --- helm/templates/hasura-migrations-job.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml index d25d3ea..f28b801 100644 --- a/helm/templates/hasura-migrations-job.yaml +++ b/helm/templates/hasura-migrations-job.yaml @@ -14,7 +14,7 @@ spec: serviceAccountName: {{ .Values.service.name }}-cli initContainers: - name: wait-for-resources - image: bitnami/kubectl:1.21 + image: bitnami/kubectl:1.24 command: [ 'sh', '-c', From 594a66bf4017ccddeada99138ad65e6f7fb4409c Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 24 Oct 2022 21:20:02 -0500 Subject: [PATCH 081/101] fix: pull secret --- helm/templates/hasura-migrations-job.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helm/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml index f28b801..2d3fdba 100644 --- a/helm/templates/hasura-migrations-job.yaml +++ b/helm/templates/hasura-migrations-job.yaml @@ -23,6 +23,8 @@ spec: containers: - name: migrations image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullSecrets: + - name: ghcr env: - name: HASURA_GRAPHQL_ENDPOINT value: http://example-hasura.{{ .Release.Namespace }}.svc.cluster.local From 1b8eb60aa98c4139d73fce9333149c864b0eaae0 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 24 Oct 2022 21:29:54 -0500 Subject: [PATCH 082/101] fix: pull secret --- helm/templates/hasura-migrations-job.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml index 2d3fdba..2401150 100644 --- a/helm/templates/hasura-migrations-job.yaml +++ b/helm/templates/hasura-migrations-job.yaml @@ -12,6 +12,8 @@ spec: sidecar.istio.io/inject: "false" spec: serviceAccountName: {{ .Values.service.name }}-cli + imagePullSecrets: + - name: ghcr initContainers: - name: wait-for-resources image: bitnami/kubectl:1.24 @@ -23,8 +25,6 @@ spec: containers: - name: migrations image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullSecrets: - - name: ghcr env: - name: HASURA_GRAPHQL_ENDPOINT value: http://example-hasura.{{ .Release.Namespace }}.svc.cluster.local From 497714d40dbc5d157142f31990058506d4bcb4e8 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 26 Oct 2022 11:33:19 -0500 Subject: [PATCH 083/101] fix: example hasura secrets + other updates --- .../external-secret-example-hasura.yaml | 16 ++++ helm/templates/hasura-migrations-job.yaml | 12 ++- helm/templates/hasura-psql.yaml | 2 +- helm/templates/ksvc.yaml | 92 ++++++++++++++++++- helm/values.yaml | 32 ++++++- 5 files changed, 146 insertions(+), 8 deletions(-) create mode 100644 helm/templates/external-secret-example-hasura.yaml diff --git a/helm/templates/external-secret-example-hasura.yaml b/helm/templates/external-secret-example-hasura.yaml new file mode 100644 index 0000000..43407bf --- /dev/null +++ b/helm/templates/external-secret-example-hasura.yaml @@ -0,0 +1,16 @@ +{{- if .Values.localDev }} +{{- else }} +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: example-hasura +spec: + secretStoreRef: + name: fake + kind: ClusterSecretStore + target: + name: example-hasura + dataFrom: + - extract: + key: /example-hasura +{{- end }} diff --git a/helm/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml index 2401150..41882f1 100644 --- a/helm/templates/hasura-migrations-job.yaml +++ b/helm/templates/hasura-migrations-job.yaml @@ -4,7 +4,7 @@ kind: Job metadata: name: {{ .Values.service.name }}-migrations-{{ lower .Values.image.tag | replace "_" "-" }} labels: - chart: {{ .Values.service.name }}-{{ lower .Values.image.tag | replace "_" "-" }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: template: metadata: @@ -28,7 +28,15 @@ spec: env: - name: HASURA_GRAPHQL_ENDPOINT value: http://example-hasura.{{ .Release.Namespace }}.svc.cluster.local +{{- if .Values.localDev }} - name: HASURA_GRAPHQL_ADMIN_SECRET - value: af18a72fc1eb42a78aa8c6d679b4842a + value: "af18a72fc1eb42a78aa8c6d679b4842a" +{{- else }} + - name: HASURA_GRAPHQL_ADMIN_SECRET + valueFrom: + secretKeyRef: + name: example-hasura + key: adminSecret +{{- end }} restartPolicy: Never {{- end }} \ No newline at end of file diff --git a/helm/templates/hasura-psql.yaml b/helm/templates/hasura-psql.yaml index e940dc9..83a9a54 100644 --- a/helm/templates/hasura-psql.yaml +++ b/helm/templates/hasura-psql.yaml @@ -35,7 +35,7 @@ spec: {{- end }} postgresql: - version: "13" + version: "14" parameters: {{ toYaml .Values.hasura.psql.parameters | indent 6 }} diff --git a/helm/templates/ksvc.yaml b/helm/templates/ksvc.yaml index 8ba49a2..e468ce7 100644 --- a/helm/templates/ksvc.yaml +++ b/helm/templates/ksvc.yaml @@ -16,12 +16,25 @@ spec: autoscaling.knative.dev/minScale: {{ .Values.knative.minScale | quote }} autoscaling.knative.dev/maxScale: {{ .Values.knative.maxScale | quote }} spec: + # affinity: + # podAntiAffinity: + # preferredDuringSchedulingIgnoredDuringExecution: + # - podAffinityTerm: + # labelSelector: + # matchExpressions: + # - key: serving.knative.dev/service + # operator: In + # values: + # - {{ .Values.service.name }} + # topologyKey: failure-domain.beta.kubernetes.io/zone + # weight: 100 containers: - - image: hasura/graphql-engine:v2.0.10 + - image: hasura/graphql-engine:v2.2.1 ports: - containerPort: {{ .Values.service.internalPort }} - protocol: TCP env: + + # metadata db - name: METADATA_POSTGRES_USERNAME valueFrom: secretKeyRef: @@ -40,6 +53,8 @@ spec: value: "5432" - name: HASURA_GRAPHQL_METADATA_DATABASE_URL value: postgres://$(METADATA_POSTGRES_USERNAME):$(METADATA_POSTGRES_PASSWORD)@$(METADATA_POSTGRES_HOST):$(METADATA_POSTGRES_PORT)/$(METADATA_POSTGRES_DATABASE) + + # ReadModel / default db - name: READMODEL_POSTGRES_USERNAME valueFrom: secretKeyRef: @@ -58,6 +73,50 @@ spec: value: "5432" - name: HASURA_GRAPHQL_DATABASE_URL value: postgres://$(READMODEL_POSTGRES_USERNAME):$(READMODEL_POSTGRES_PASSWORD)@$(READMODEL_POSTGRES_HOST):$(READMODEL_POSTGRES_PORT)/$(READMODEL_POSTGRES_DATABASE) + + + # sourced db + - name: SOURCED_POSTGRES_USERNAME + valueFrom: + secretKeyRef: + name: {{ .Values.sourced.psql.username }}.{{ .Values.sourced.psql.name }}.credentials.postgresql.acid.zalan.do + key: username + - name: SOURCED_POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.sourced.psql.username }}.{{ .Values.sourced.psql.name }}.credentials.postgresql.acid.zalan.do + key: password + - name: SOURCED_POSTGRES_DATABASE + value: {{ .Values.sourced.psql.database }} + - name: SOURCED_POSTGRES_HOST + value: {{ .Values.sourced.psql.hostname.write }}.{{ .Release.Namespace }}.svc.cluster.local + - name: SOURCED_POSTGRES_PORT + value: "5432" + - name: SOURCED_DATABASE_URL + value: postgres://$(SOURCED_POSTGRES_USERNAME):$(SOURCED_POSTGRES_PASSWORD)@$(SOURCED_POSTGRES_HOST):$(SOURCED_POSTGRES_PORT)/$(SOURCED_POSTGRES_DATABASE) + + + # web3auth db + - name: WEB3AUTH_POSTGRES_USERNAME + valueFrom: + secretKeyRef: + name: {{ .Values.web3auth.psql.username }}.{{ .Values.web3auth.psql.name }}.credentials.postgresql.acid.zalan.do + key: username + - name: WEB3AUTH_POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.web3auth.psql.username }}.{{ .Values.web3auth.psql.name }}.credentials.postgresql.acid.zalan.do + key: password + - name: WEB3AUTH_POSTGRES_DATABASE + value: {{ .Values.web3auth.psql.database }} + - name: WEB3AUTH_POSTGRES_HOST + value: {{ .Values.web3auth.psql.hostname.write }}.{{ .Release.Namespace }}.svc.cluster.local + - name: WEB3AUTH_POSTGRES_PORT + value: "5432" + - name: WEB3AUTH_DATABASE_URL + value: postgres://$(WEB3AUTH_POSTGRES_USERNAME):$(WEB3AUTH_POSTGRES_PASSWORD)@$(WEB3AUTH_POSTGRES_HOST):$(WEB3AUTH_POSTGRES_PORT)/$(WEB3AUTH_POSTGRES_DATABASE) + + ## enable the console served by server - need to run `hasura console` to access instead - name: HASURA_GRAPHQL_ENABLE_CONSOLE value: "false" @@ -66,10 +125,37 @@ spec: value: {{ .Values.hasura.devMode | quote }} - name: HASURA_GRAPHQL_CORS_DOMAIN value: '*' + - name: HASURA_GRAPHQL_UNAUTHORIZED_ROLE + value: anonymous + +{{- if .Values.localDev }} - name: HASURA_GRAPHQL_ADMIN_SECRET - value: af18a72fc1eb42a78aa8c6d679b4842a + value: "af18a72fc1eb42a78aa8c6d679b4842a" - name: HASURA_GRAPHQL_JWT_SECRET value: '{"type":"HS256", "key": "a114d68b22894049a7c2203a7228fdcde922a1210675427795b7bf9a0317e16d"}' + - name: EXAMPLE_TODO_MODEL + value: host.docker.internal:5002 + - name: EXAMPLE_POLICY_SERVICE + value: host.docker.internal:5020 +{{- else }} + - name: HASURA_GRAPHQL_ADMIN_SECRET + valueFrom: + secretKeyRef: + name: example-hasura + key: adminSecret + - name: HASURA_GRAPHQL_JWT_SECRET + valueFrom: + secretKeyRef: + name: example-hasura + key: jwtSecret + + - name: EXAMPLE_TODO_MODEL + value: example-todo-model-service.{{ .Release.Namespace }}.svc.cluster.local + - name: EXAMPLE_POLICY_SERVICE + value: example-policy-service.{{ .Release.Namespace }}.svc.cluster.local + +{{- end }} + {{- range $pkey, $pval := .Values.env }} - name: {{ $pkey }} value: {{ quote $pval }} diff --git a/helm/values.yaml b/helm/values.yaml index 63ec49b..6c25d47 100755 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -9,6 +9,8 @@ image: # define environment variables here as a map of key: value env: +secretEnv: staging + knativeDeploy: true knative: minScale: 1 @@ -48,10 +50,15 @@ hasura: psql: name: example-hasura-metadata-postgresql database: metadata - username: metadata + username: postgres + hostname: + write: example-hasura-metadata-postgresql + read: example-hasura-metadata-postgresql-repl + pool: example-hasura-metadata-db-pgpool numberOfInstances: 1 enableLogicalBackup: false enableShmVolume: true + # we're using pgpool instead of pgbouncer with zalando pgo - so, we already have a connection pooler - don't enable. enableConnectionPooler: false enableReplicaConnectionPooler: false connectionPooler: @@ -99,7 +106,28 @@ readmodel: psql: name: example-readmodel-postgresql database: readmodel - username: readmodel + username: postgres hostname: write: example-readmodel-postgresql read: example-readmodel-postgresql-repl + pool: example-readmodel-pgpool + +sourced: + psql: + name: example-sourced-db-postgresql + database: sourced + username: postgres + hostname: + write: example-sourced-db-postgresql + read: example-sourced-db-postgresql-repl + pool: example-sourced-db-pgpool + +web3auth: + psql: + name: web3auth-db-postgresql + database: web3auth + username: postgres + hostname: + write: web3auth-db-postgresql + read: web3auth-db-postgresql-repl + pool: web3auth-db-pgpool \ No newline at end of file From 4e6e584a7a1b071dd62ce29b90c1003680a94485 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 26 Oct 2022 11:37:07 -0500 Subject: [PATCH 084/101] fix: missing port protocol --- helm/templates/ksvc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm/templates/ksvc.yaml b/helm/templates/ksvc.yaml index e468ce7..0229288 100644 --- a/helm/templates/ksvc.yaml +++ b/helm/templates/ksvc.yaml @@ -32,6 +32,7 @@ spec: - image: hasura/graphql-engine:v2.2.1 ports: - containerPort: {{ .Values.service.internalPort }} + protocol: TCP env: # metadata db From ea6fcd0032b281be54886cebf2eabe5244174013 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 26 Oct 2022 13:37:21 -0500 Subject: [PATCH 085/101] feat: add db metadata --- config.yaml | 2 +- metadata/databases/databases.yaml | 18 ++++++++++++++++++ .../databases/default/tables/public_todos.yaml | 5 +++++ .../databases/sourced/tables/public_event.yaml | 3 +++ metadata/databases/sourced/tables/tables.yaml | 1 + .../web3auth/tables/public_refresh_tokens.yaml | 7 +++++++ .../web3auth/tables/public_users.yaml | 11 +++++++++++ metadata/databases/web3auth/tables/tables.yaml | 2 ++ 8 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 metadata/databases/sourced/tables/public_event.yaml create mode 100644 metadata/databases/sourced/tables/tables.yaml create mode 100644 metadata/databases/web3auth/tables/public_refresh_tokens.yaml create mode 100644 metadata/databases/web3auth/tables/public_users.yaml create mode 100644 metadata/databases/web3auth/tables/tables.yaml diff --git a/config.yaml b/config.yaml index 7e76f4b..c254308 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ version: 3 -endpoint: http://example-hasura.default.127.0.0.1.sslip.io +endpoint: http://example-hasura.example-prod-env.127.0.0.1.sslip.io metadata_directory: metadata actions: kind: synchronous diff --git a/metadata/databases/databases.yaml b/metadata/databases/databases.yaml index 65a11b2..5c9f4ff 100644 --- a/metadata/databases/databases.yaml +++ b/metadata/databases/databases.yaml @@ -12,3 +12,21 @@ retries: 1 use_prepared_statements: true tables: "!include default/tables/tables.yaml" +- name: sourced + kind: postgres + configuration: + connection_info: + database_url: + from_env: SOURCED_DATABASE_URL + isolation_level: read-committed + use_prepared_statements: false + tables: "!include sourced/tables/tables.yaml" +- name: web3auth + kind: postgres + configuration: + connection_info: + database_url: + from_env: WEB3AUTH_DATABASE_URL + isolation_level: read-committed + use_prepared_statements: false + tables: "!include web3auth/tables/tables.yaml" diff --git a/metadata/databases/default/tables/public_todos.yaml b/metadata/databases/default/tables/public_todos.yaml index 9d8e240..d672b25 100644 --- a/metadata/databases/default/tables/public_todos.yaml +++ b/metadata/databases/default/tables/public_todos.yaml @@ -1,6 +1,10 @@ table: name: todos schema: public +object_relationships: +- name: web3auth_user + using: + foreign_key_constraint_on: address select_permissions: - permission: allow_aggregations: true @@ -14,4 +18,5 @@ select_permissions: filter: address: _eq: X-Hasura-User-Id + limit: 25 role: user diff --git a/metadata/databases/sourced/tables/public_event.yaml b/metadata/databases/sourced/tables/public_event.yaml new file mode 100644 index 0000000..45c9339 --- /dev/null +++ b/metadata/databases/sourced/tables/public_event.yaml @@ -0,0 +1,3 @@ +table: + name: event + schema: public diff --git a/metadata/databases/sourced/tables/tables.yaml b/metadata/databases/sourced/tables/tables.yaml new file mode 100644 index 0000000..5aedb29 --- /dev/null +++ b/metadata/databases/sourced/tables/tables.yaml @@ -0,0 +1 @@ +- "!include public_event.yaml" diff --git a/metadata/databases/web3auth/tables/public_refresh_tokens.yaml b/metadata/databases/web3auth/tables/public_refresh_tokens.yaml new file mode 100644 index 0000000..a7cd547 --- /dev/null +++ b/metadata/databases/web3auth/tables/public_refresh_tokens.yaml @@ -0,0 +1,7 @@ +table: + name: refresh_tokens + schema: public +object_relationships: +- name: user + using: + foreign_key_constraint_on: address diff --git a/metadata/databases/web3auth/tables/public_users.yaml b/metadata/databases/web3auth/tables/public_users.yaml new file mode 100644 index 0000000..7bf39e4 --- /dev/null +++ b/metadata/databases/web3auth/tables/public_users.yaml @@ -0,0 +1,11 @@ +table: + name: users + schema: public +array_relationships: +- name: refresh_tokens + using: + foreign_key_constraint_on: + column: address + table: + name: refresh_tokens + schema: public diff --git a/metadata/databases/web3auth/tables/tables.yaml b/metadata/databases/web3auth/tables/tables.yaml new file mode 100644 index 0000000..24715dc --- /dev/null +++ b/metadata/databases/web3auth/tables/tables.yaml @@ -0,0 +1,2 @@ +- "!include public_refresh_tokens.yaml" +- "!include public_users.yaml" From f8214836605a935bdf1cae558e82066f8d008c0d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 26 Oct 2022 13:39:29 -0500 Subject: [PATCH 086/101] fix: model env var for actions --- metadata/actions.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/metadata/actions.yaml b/metadata/actions.yaml index b55a6db..642d60f 100644 --- a/metadata/actions.yaml +++ b/metadata/actions.yaml @@ -2,25 +2,25 @@ actions: - name: command_todo_complete definition: kind: synchronous - handler: http://host.docker.internal:5002/todo.complete + handler: http://{{IG_TODO_MODEL}}/todo.complete permissions: - role: user - name: command_todo_initialize definition: kind: synchronous - handler: http://host.docker.internal:5002/todo.initialize + handler: http://{{IG_TODO_MODEL}}/todo.initialize permissions: - role: user - name: command_todo_remove definition: kind: synchronous - handler: http://host.docker.internal:5002/todo.remove + handler: http://{{IG_TODO_MODEL}}/todo.remove permissions: - role: user - name: command_todo_reopen definition: kind: synchronous - handler: http://host.docker.internal:5002/todo.reopen + handler: http://{{IG_TODO_MODEL}}/todo.reopen permissions: - role: user custom_types: From 88912c5f97631ccf208a93ad5bc84ea19736ba01 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Wed, 26 Oct 2022 13:46:30 -0500 Subject: [PATCH 087/101] feat: missing table --- metadata/actions.yaml | 8 ++++---- .../default/tables/public_web3auth_users.yaml | 18 ++++++++++++++++++ metadata/databases/default/tables/tables.yaml | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 metadata/databases/default/tables/public_web3auth_users.yaml diff --git a/metadata/actions.yaml b/metadata/actions.yaml index 642d60f..1cacef3 100644 --- a/metadata/actions.yaml +++ b/metadata/actions.yaml @@ -2,25 +2,25 @@ actions: - name: command_todo_complete definition: kind: synchronous - handler: http://{{IG_TODO_MODEL}}/todo.complete + handler: http://{{EXAMPLE_TODO_MODEL}}/todo.complete permissions: - role: user - name: command_todo_initialize definition: kind: synchronous - handler: http://{{IG_TODO_MODEL}}/todo.initialize + handler: http://{{EXAMPLE_TODO_MODEL}}/todo.initialize permissions: - role: user - name: command_todo_remove definition: kind: synchronous - handler: http://{{IG_TODO_MODEL}}/todo.remove + handler: http://{{EXAMPLE_TODO_MODEL}}/todo.remove permissions: - role: user - name: command_todo_reopen definition: kind: synchronous - handler: http://{{IG_TODO_MODEL}}/todo.reopen + handler: http://{{EXAMPLE_TODO_MODEL}}/todo.reopen permissions: - role: user custom_types: diff --git a/metadata/databases/default/tables/public_web3auth_users.yaml b/metadata/databases/default/tables/public_web3auth_users.yaml new file mode 100644 index 0000000..0881298 --- /dev/null +++ b/metadata/databases/default/tables/public_web3auth_users.yaml @@ -0,0 +1,18 @@ +table: + name: web3auth_users + schema: public +select_permissions: +- permission: + columns: + - address + - username + filter: {} + limit: 25 + role: anonymous +- permission: + columns: + - address + - username + filter: {} + limit: 25 + role: user diff --git a/metadata/databases/default/tables/tables.yaml b/metadata/databases/default/tables/tables.yaml index 467d14a..50babde 100644 --- a/metadata/databases/default/tables/tables.yaml +++ b/metadata/databases/default/tables/tables.yaml @@ -1 +1,2 @@ - "!include public_todos.yaml" +- "!include public_web3auth_users.yaml" \ No newline at end of file From 806e4c657b73046487585fd65b85186eded34614 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 31 Oct 2022 01:36:11 -0500 Subject: [PATCH 088/101] fix: waves --- helm/README.md | 3 --- helm/templates/_helpers.tpl | 16 -------------- .../external-secret-example-hasura.yaml | 2 ++ helm/templates/hasura-migrations-job.yaml | 1 + helm/templates/hasura-psql.yaml | 2 ++ helm/templates/ksvc.yaml | 3 +-- helm/templates/service.yaml | 22 ------------------- helm/values.yaml | 3 --- 8 files changed, 6 insertions(+), 46 deletions(-) delete mode 100644 helm/README.md delete mode 100755 helm/templates/_helpers.tpl delete mode 100644 helm/templates/service.yaml diff --git a/helm/README.md b/helm/README.md deleted file mode 100644 index a9044a9..0000000 --- a/helm/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# example-hasura - -Auth Example's Hasura metadata, migrations, and seeds, as well as charts to run and configure Hasura with that information. \ No newline at end of file diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl deleted file mode 100755 index f0d83d2..0000000 --- a/helm/templates/_helpers.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -*/}} -{{- define "fullname" -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/helm/templates/external-secret-example-hasura.yaml b/helm/templates/external-secret-example-hasura.yaml index 43407bf..4552429 100644 --- a/helm/templates/external-secret-example-hasura.yaml +++ b/helm/templates/external-secret-example-hasura.yaml @@ -4,6 +4,8 @@ apiVersion: external-secrets.io/v1beta1 kind: ExternalSecret metadata: name: example-hasura + annotations: + argocd.argoproj.io/sync-wave: "-1" spec: secretStoreRef: name: fake diff --git a/helm/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml index 41882f1..b4f363f 100644 --- a/helm/templates/hasura-migrations-job.yaml +++ b/helm/templates/hasura-migrations-job.yaml @@ -10,6 +10,7 @@ spec: metadata: annotations: sidecar.istio.io/inject: "false" + argocd.argoproj.io/sync-wave: "2" spec: serviceAccountName: {{ .Values.service.name }}-cli imagePullSecrets: diff --git a/helm/templates/hasura-psql.yaml b/helm/templates/hasura-psql.yaml index 83a9a54..89601a5 100644 --- a/helm/templates/hasura-psql.yaml +++ b/helm/templates/hasura-psql.yaml @@ -2,6 +2,8 @@ apiVersion: "acid.zalan.do/v1" kind: postgresql metadata: name: example-hasura-metadata-postgresql + annotations: + argocd.argoproj.io/sync-wave: "-1" spec: teamId: example diff --git a/helm/templates/ksvc.yaml b/helm/templates/ksvc.yaml index 0229288..22a20fd 100644 --- a/helm/templates/ksvc.yaml +++ b/helm/templates/ksvc.yaml @@ -1,4 +1,3 @@ -{{- if .Values.knativeDeploy }} apiVersion: serving.knative.dev/v1 kind: Service metadata: @@ -6,6 +5,7 @@ metadata: labels: chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" annotations: + argocd.argoproj.io/sync-wave: "1" {{- if .Values.knative.subdomain }} custom-hostname: {{ .Values.knative.subdomain }} {{- end }} @@ -169,4 +169,3 @@ spec: # path: {{ .Values.livenessProbe.probePath | default .Values.probePath }} resources: {{ toYaml .Values.resources | indent 10 }} -{{- end }} \ No newline at end of file diff --git a/helm/templates/service.yaml b/helm/templates/service.yaml deleted file mode 100644 index b2ed9c0..0000000 --- a/helm/templates/service.yaml +++ /dev/null @@ -1,22 +0,0 @@ -{{- if or .Values.knativeDeploy }} -{{- else }} -apiVersion: v1 -kind: Service -metadata: - name: {{ .Values.service.name }} - labels: - app: {{ .Values.service.name }} -{{- if .Values.service.annotations }} - annotations: -{{ toYaml .Values.service.annotations | indent 4 }} -{{- end }} -spec: - ports: - - protocol: TCP - port: {{ .Values.service.externalPort }} - targetPort: {{ .Values.service.internalPort }} - name: http - selector: - app: {{ .Values.service.name }} - type: {{ .Values.service.type }} -{{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index 6c25d47..e8219cd 100755 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -9,9 +9,6 @@ image: # define environment variables here as a map of key: value env: -secretEnv: staging - -knativeDeploy: true knative: minScale: 1 maxScale: 3 From eec44cc93c0c737073652efea25967c1984d1fca Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 31 Oct 2022 16:12:56 -0500 Subject: [PATCH 089/101] feat: local dev --- Makefile | 34 +++------------------ config.yaml | 2 +- helm/templates/ksvc.yaml | 18 ++++------- helm/values.yaml | 2 ++ preview/Kptfile | 11 ------- preview/helmfile.yaml | 59 ------------------------------------- preview/values.preview.yaml | 2 -- preview/values.verify.yaml | 3 -- preview/values.yaml.gotmpl | 11 ------- 9 files changed, 13 insertions(+), 129 deletions(-) delete mode 100644 preview/Kptfile delete mode 100644 preview/helmfile.yaml delete mode 100644 preview/values.preview.yaml delete mode 100644 preview/values.verify.yaml delete mode 100644 preview/values.yaml.gotmpl diff --git a/Makefile b/Makefile index 48ddf0d..bf648ce 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,12 @@ -HASURA_ENDPOINT?=http://example-hasura.default.127.0.0.1.sslip.io +HASURA_ENDPOINT?=http://example-hasura.example-local-env.127.0.0.1.sslip.io LOCAL_DEV_CLUSTER ?= rancher-desktop NOW := $(shell date +%m_%d_%Y_%H_%M) SERVICE_NAME := example-hasura -HASURA_GRAPHQL_DATABASE_URL=postgres://readmodel:$(kubectl get secret readmodel.example-readmodel-postgresql.credentials.postgresql.acid.zalan.do)@readmodel.default.cluster.svc.local:5432/readmodel +HASURA_GRAPHQL_DATABASE_URL=postgres://readmodel:$(kubectl get secret readmodel.example-readmodel-postgresql.credentials.postgresql.acid.zalan.do)@readmodel.example-local-env.cluster.svc.local:5432/readmodel # Does what's described in Readme, runs in the background - `attach-to-tmux-session` to attach to the session where it is running -onboard: refresh-kind-image +onboard: + echo "Nothing to do. Deploy using gitops config." open: code . @@ -14,30 +15,3 @@ migrate: hasura metadata apply --endpoint $(HASURA_ENDPOINT) hasura migrate apply --all-databases --endpoint $(HASURA_ENDPOINT) hasura metadata reload --endpoint $(HASURA_ENDPOINT) - -build-new-local-image: - kubectl ctx $(LOCAL_DEV_CLUSTER) - docker build -t $(SERVICE_NAME) . - docker tag $(SERVICE_NAME):latest dev.local/$(SERVICE_NAME):$(NOW) - -load-local-image-to-kind: - kubectl ctx $(LOCAL_DEV_CLUSTER) - kind --name local-dev-cluster load docker-image dev.local/$(SERVICE_NAME):$(NOW) - -deploy-to-local-cluster: - kubectl ctx $(LOCAL_DEV_CLUSTER) - helm template helm/ \ - -f helm/values.yaml \ - --set image.repository=dev.local/$(SERVICE_NAME),image.tag=$(NOW) \ - | kubectl apply -f - - kubectl wait --for=condition=ready ksvc example-hasura --timeout=600s - -delete-local-deployment: - kubectl ctx $(LOCAL_DEV_CLUSTER) - helm template helm/ \ - -f helm/values.yaml \ - --set image.repository=dev.local/$(SERVICE_NAME),image.tag=$(NOW) \ - | kubectl delete -f - - -refresh-kind-image: build-new-local-image load-local-image-to-kind deploy-to-local-cluster -hard-refresh-kind-image: delete-local-deployment build-new-local-image load-local-image-to-kind deploy-to-local-cluster diff --git a/config.yaml b/config.yaml index c254308..b0b420d 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ version: 3 -endpoint: http://example-hasura.example-prod-env.127.0.0.1.sslip.io +endpoint: http://example-hasura.example-local-env.127.0.0.1.sslip.io metadata_directory: metadata actions: kind: synchronous diff --git a/helm/templates/ksvc.yaml b/helm/templates/ksvc.yaml index 22a20fd..916fc7e 100644 --- a/helm/templates/ksvc.yaml +++ b/helm/templates/ksvc.yaml @@ -129,16 +129,6 @@ spec: - name: HASURA_GRAPHQL_UNAUTHORIZED_ROLE value: anonymous -{{- if .Values.localDev }} - - name: HASURA_GRAPHQL_ADMIN_SECRET - value: "af18a72fc1eb42a78aa8c6d679b4842a" - - name: HASURA_GRAPHQL_JWT_SECRET - value: '{"type":"HS256", "key": "a114d68b22894049a7c2203a7228fdcde922a1210675427795b7bf9a0317e16d"}' - - name: EXAMPLE_TODO_MODEL - value: host.docker.internal:5002 - - name: EXAMPLE_POLICY_SERVICE - value: host.docker.internal:5020 -{{- else }} - name: HASURA_GRAPHQL_ADMIN_SECRET valueFrom: secretKeyRef: @@ -149,12 +139,16 @@ spec: secretKeyRef: name: example-hasura key: jwtSecret - +{{- if .Values.local }} + - name: EXAMPLE_TODO_MODEL + value: host.docker.internal:5002 + - name: EXAMPLE_POLICY_SERVICE + value: host.docker.internal:5020 +{{- else }} - name: EXAMPLE_TODO_MODEL value: example-todo-model-service.{{ .Release.Namespace }}.svc.cluster.local - name: EXAMPLE_POLICY_SERVICE value: example-policy-service.{{ .Release.Namespace }}.svc.cluster.local - {{- end }} {{- range $pkey, $pval := .Values.env }} diff --git a/helm/values.yaml b/helm/values.yaml index e8219cd..240318b 100755 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -13,6 +13,8 @@ knative: minScale: 1 maxScale: 3 +local: false + runMigrations: true runSeeds: false diff --git a/preview/Kptfile b/preview/Kptfile deleted file mode 100644 index ac0f2f1..0000000 --- a/preview/Kptfile +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kpt.dev/v1alpha1 -kind: Kptfile -metadata: - name: preview -upstream: - type: git - git: - commit: 1064367e5df53ed8c0c00998fd6fe89a2b9100ce - repo: https://github.com/jenkins-x/jx3-pipeline-catalog - directory: /helm/preview - ref: master diff --git a/preview/helmfile.yaml b/preview/helmfile.yaml deleted file mode 100644 index eed56b0..0000000 --- a/preview/helmfile.yaml +++ /dev/null @@ -1,59 +0,0 @@ -environments: - default: - values: - - jx-values.yaml -repositories: -- name: jx3 - url: https://jenkins-x-charts.github.io/repo -- name: cne - url: https://cloudnativeentrepreneur.github.io/helm-charts/ -releases: -- chart: jx3/jx-verify - name: jx-verify - namespace: '{{ requiredEnv "PREVIEW_NAMESPACE" }}' - values: - - values.verify.yaml -- chart: cne/example-readmodel - name: example-readmodel - version: 0.0.1 - wait: true - namespace: '{{ requiredEnv "PREVIEW_NAMESPACE" }}' - values: - - jx-values.yaml -- chart: cne/sourced-psql-event-store - name: sourced-psql-event-store - version: 0.0.1 - wait: true - namespace: '{{ requiredEnv "PREVIEW_NAMESPACE" }}' - values: - - jx-values.yaml -- chart: '../charts/{{ requiredEnv "APP_NAME" }}' - name: preview - wait: true - createNamespace: true - namespace: '{{ requiredEnv "PREVIEW_NAMESPACE" }}' - values: - - jx-values.yaml - - values.preview.yaml - - values.yaml.gotmpl - hooks: - - events: ["presync"] - showlogs: true - command: "jx" - args: - - secret - - copy - - --create-namespace - - --selector - - "secret.jenkins-x.io/replica-source=true" - - --to - - '{{ requiredEnv "PREVIEW_NAMESPACE" }}' - - events: ["presync"] - showlogs: true - command: "kubectl" - args: - - label - - namespace - - '{{ requiredEnv "PREVIEW_NAMESPACE" }}' - - istio-injection=enabled - - --overwrite=true diff --git a/preview/values.preview.yaml b/preview/values.preview.yaml deleted file mode 100644 index 14eed73..0000000 --- a/preview/values.preview.yaml +++ /dev/null @@ -1,2 +0,0 @@ -env: -vaultRole: jx-vault diff --git a/preview/values.verify.yaml b/preview/values.verify.yaml deleted file mode 100644 index 1d7e3c2..0000000 --- a/preview/values.verify.yaml +++ /dev/null @@ -1,3 +0,0 @@ -verifyJob: - podAnnotations: - sidecar.istio.io/inject: "false" diff --git a/preview/values.yaml.gotmpl b/preview/values.yaml.gotmpl deleted file mode 100644 index 4e4cabc..0000000 --- a/preview/values.yaml.gotmpl +++ /dev/null @@ -1,11 +0,0 @@ -jxRequirements: - ingress: - namespaceSubDomain: "-pr{{ requiredEnv "PULL_NUMBER" }}." - -image: - repository: "{{ requiredEnv "DOCKER_REGISTRY" }}/{{ requiredEnv "DOCKER_REGISTRY_ORG" }}/{{ requiredEnv "APP_NAME" }}" - tag: "{{ requiredEnv "VERSION" }}" - pullPolicy: "Always" - -knative: - subdomain: "{{ requiredEnv "APP_NAME" }}-pr-{{ requiredEnv "PULL_NUMBER" }}" \ No newline at end of file From 834bc15d041dd2622fece2764def43fd6856a7f2 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 31 Oct 2022 16:18:25 -0500 Subject: [PATCH 090/101] fix: rm unused files --- OWNERS | 4 ---- OWNERS_ALIASES | 6 ------ 2 files changed, 10 deletions(-) delete mode 100644 OWNERS delete mode 100644 OWNERS_ALIASES diff --git a/OWNERS b/OWNERS deleted file mode 100644 index b316862..0000000 --- a/OWNERS +++ /dev/null @@ -1,4 +0,0 @@ -approvers: -- patrickleet -reviewers: -- patrickleet diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES deleted file mode 100644 index 420b045..0000000 --- a/OWNERS_ALIASES +++ /dev/null @@ -1,6 +0,0 @@ -aliases: -- patrickleet -best-approvers: -- patrickleet -best-reviewers: -- patrickleet From f863afda323458a49617b305f1126609c39acc43 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Fri, 4 Nov 2022 20:57:36 -0500 Subject: [PATCH 091/101] fix(job): migrations post sync hook --- helm/templates/hasura-migrations-job.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml index b4f363f..56b5894 100644 --- a/helm/templates/hasura-migrations-job.yaml +++ b/helm/templates/hasura-migrations-job.yaml @@ -11,6 +11,7 @@ spec: annotations: sidecar.istio.io/inject: "false" argocd.argoproj.io/sync-wave: "2" + argocd.argoproj.io/hook: PostSync spec: serviceAccountName: {{ .Values.service.name }}-cli imagePullSecrets: From 05cf368a38e299d4234849361af88c2280944427 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sat, 5 Nov 2022 15:56:57 -0500 Subject: [PATCH 092/101] fix(job): migrations post sync hook only - rm wave --- config.yaml | 2 +- helm/templates/hasura-migrations-job.yaml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index b0b420d..c254308 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ version: 3 -endpoint: http://example-hasura.example-local-env.127.0.0.1.sslip.io +endpoint: http://example-hasura.example-prod-env.127.0.0.1.sslip.io metadata_directory: metadata actions: kind: synchronous diff --git a/helm/templates/hasura-migrations-job.yaml b/helm/templates/hasura-migrations-job.yaml index 56b5894..e1ad9cf 100644 --- a/helm/templates/hasura-migrations-job.yaml +++ b/helm/templates/hasura-migrations-job.yaml @@ -10,7 +10,6 @@ spec: metadata: annotations: sidecar.istio.io/inject: "false" - argocd.argoproj.io/sync-wave: "2" argocd.argoproj.io/hook: PostSync spec: serviceAccountName: {{ .Values.service.name }}-cli From 529c551643af6845293d1f64c3ae91c094c93a8b Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sat, 5 Nov 2022 19:44:19 -0500 Subject: [PATCH 093/101] fix: sync ksvc in wave 0 --- helm/templates/ksvc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/ksvc.yaml b/helm/templates/ksvc.yaml index 916fc7e..8e4e67b 100644 --- a/helm/templates/ksvc.yaml +++ b/helm/templates/ksvc.yaml @@ -5,7 +5,7 @@ metadata: labels: chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" annotations: - argocd.argoproj.io/sync-wave: "1" + argocd.argoproj.io/sync-wave: "0" {{- if .Values.knative.subdomain }} custom-hostname: {{ .Values.knative.subdomain }} {{- end }} From ebb4201c9e36bc4cc2e660e5c7555933852bab2a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sat, 5 Nov 2022 19:54:43 -0500 Subject: [PATCH 094/101] feat: update hasura version --- Dockerfile | 2 +- helm/templates/ksvc.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5ae6435..32bb125 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # This container runs migrations - the main hasura service is hasura/graphql-engine:v2.x.x -FROM hasura/graphql-engine:v2.0.10.cli-migrations-v3 +FROM hasura/graphql-engine:v2.14.0.cli-migrations-v3 # we are managing migrations with schemahero - so let's avoid copying it here unless we go back to using Hasura for migrations. # we still want the metadata and config though diff --git a/helm/templates/ksvc.yaml b/helm/templates/ksvc.yaml index 8e4e67b..b63758a 100644 --- a/helm/templates/ksvc.yaml +++ b/helm/templates/ksvc.yaml @@ -29,7 +29,7 @@ spec: # topologyKey: failure-domain.beta.kubernetes.io/zone # weight: 100 containers: - - image: hasura/graphql-engine:v2.2.1 + - image: hasura/graphql-engine:v2.14.0 ports: - containerPort: {{ .Values.service.internalPort }} protocol: TCP From fe5b91cb69df340625a2fc96f1a0415b0487da59 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sat, 5 Nov 2022 19:56:26 -0500 Subject: [PATCH 095/101] fix: missed version --- docker-compose.default-example.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.default-example.yaml b/docker-compose.default-example.yaml index e201807..0d51713 100644 --- a/docker-compose.default-example.yaml +++ b/docker-compose.default-example.yaml @@ -8,7 +8,7 @@ services: environment: POSTGRES_PASSWORD: postgrespassword graphql-engine: - image: hasura/graphql-engine:v2.0.10 + image: hasura/graphql-engine:v2.14.0 ports: - "8080:8080" depends_on: From 16c1b536d7d5fcfbb5c0b969df9227b22b3ab0e2 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Sat, 5 Nov 2022 20:15:14 -0500 Subject: [PATCH 096/101] feat: previews (#10) --- .github/workflows/pr-close.yaml | 48 +++++--- .github/workflows/pr.yaml | 127 +++++++++++++-------- .github/workflows/publish-and-promote.yaml | 18 ++- .github/workflows/release.yaml | 22 ---- helm/values.yaml | 12 +- preview/helm/Chart.yaml | 6 + preview/helm/templates/app.yaml | 29 +++++ preview/helm/templates/environment.yaml | 23 ++++ preview/helm/values.yaml | 5 + 9 files changed, 189 insertions(+), 101 deletions(-) create mode 100644 preview/helm/Chart.yaml create mode 100644 preview/helm/templates/app.yaml create mode 100644 preview/helm/templates/environment.yaml create mode 100644 preview/helm/values.yaml diff --git a/.github/workflows/pr-close.yaml b/.github/workflows/pr-close.yaml index 0e6a3fb..cf19868 100644 --- a/.github/workflows/pr-close.yaml +++ b/.github/workflows/pr-close.yaml @@ -7,31 +7,41 @@ jobs: pr-close: runs-on: ubuntu-latest + + permissions: + issues: write + pull-requests: write + contents: write steps: - - name: downcase REPO - run: | - echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - - - name: Checkout + - name: Checkout Preview Environments Project uses: actions/checkout@v3 + with: + repository: cloudnativeentrepreneur/example-preview-envs + persist-credentials: false - - name: test + - name: Commit Preview Env Changes run: | - echo "Test" + rm helm/templates/${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}.yaml + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add . + git commit -m "remove: ${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}" - # - name: Setup Kube config - # uses: azure/k8s-set-context@v3 - # with: - # method: kubeconfig - # kubeconfig: ${{ secrets.KUBE_CONFIG }} + - name: Push Preview Env Changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GH_ORG_TOKEN }} + repository: cloudnativeentrepreneur/example-preview-envs - # - name: Delete preview - # run: | - # # Install vCluster - # curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; - # sudo mv vcluster /usr/local/bin; + - name: Create comment about garbage collection + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + Your preview environment has been removed. It will be garbage collected soon. - # # Delete the cluster - # vcluster delete demo-hasura-pr-${{ github.event.pull_request.number }} --namespace prs + To create a new preview environment, open a new pull request. + edit-mode: replace \ No newline at end of file diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0beb8f8..bdce00d 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -3,33 +3,20 @@ name: pr on: pull_request: + branches: + - main jobs: - # quality: - # runs-on: ubuntu-latest - - # strategy: - # matrix: - # node-version: [18.x] - # # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - # steps: - # - uses: actions/checkout@v2 - # - name: Use Node.js ${{ matrix.node-version }} - # uses: actions/setup-node@v2 - # with: - # node-version: ${{ matrix.node-version }} - # cache: 'npm' - # - run: npm ci - # - run: npm run lint --if-present - # - run: npm run build --if-present - # - run: npm test - # - run: npx codecov - preview: - needs: quality runs-on: ubuntu-latest + + permissions: + packages: write + contents: write + issues: write + pull-requests: write + steps: - name: downcase REPO @@ -65,34 +52,76 @@ jobs: push: true tags: | ${{ steps.meta.outputs.tags }} + ghcr.io/${{ env.REPO }}:pr-${{ github.event.pull_request.number }}-${{ github.sha }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max + + - name: Setup Helm + uses: azure/setup-helm@v3 - # - name: Setup Kube config - # uses: azure/k8s-set-context@v3 - # with: - # method: kubeconfig - # kubeconfig: ${{ secrets.KUBE_CONFIG }} - - # - name: Deploy preview - # run: | - # # Install vCluster - # curl -s -L "https://github.com/loft-sh/vcluster/releases/latest" | sed -nE 's!.*"([^"]*vcluster-linux-amd64)".*!https://github.com\1!p' | xargs -n 1 curl -L -o vcluster && chmod +x vcluster; - # sudo mv vcluster /usr/local/bin; - - # # Create a cluster - # vcluster create example-hasura-pr-${{ github.event.pull_request.number }} --namespace prs --expose - # vcluster connect example-hasura-pr-${{ github.event.pull_request.number }} --namespace prs - # export KUBECONFIG=$PWD/kubeconfig.yaml - # sleep 5 - # kubectl get ingresses - - # # Deploy - # cd kustomize/overlays/preview - # kustomize edit set image ${{ env.REPO }}=${{ env.REPO }}:pr-${{ github.event.pull_request.number }} - # kustomize build | kubectl apply --filename - - # kubectl rollout status deployment example-hasura - # - name: Test - # run: | - # echo "I was to lazy to write tests" + - name: Checkout Preview Environments Project + uses: actions/checkout@v3 + with: + path: previews + repository: cloudnativeentrepreneur/example-preview-envs + persist-credentials: false + + - name: Create Preview from Helm template + run: | + mkdir -p previews/helm/templates + helm template preview/helm/ \ + --set pr=pr-${{ github.event.pull_request.number }} \ + --set tag=pr-${{ github.event.pull_request.number }}-${{ github.sha }} \ + --set headRef=${{ github.head_ref }} \ + --set repository.name=${{ github.event.repository.name }} \ + > previews/helm/templates/${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}.yaml + + - name: Commit Preview Env Changes + run: | + cd previews + + if output=$(git status --porcelain) && [ -z "$output" ]; then + # Working directory clean + + echo "No changes to commit" + else + # Uncommitted changes + + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add -A + git commit -m "promote: ${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }} ${{ github.sha }}" + fi + + - name: Push Preview Env Changes + uses: ad-m/github-push-action@master + with: + directory: previews + github_token: ${{ secrets.GH_ORG_TOKEN }} + repository: cloudnativeentrepreneur/example-preview-envs + + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Your preview environment + + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + Your preview environment has been published! :rocket: + + This service doesn't have a public URL. + + You can verify the PR is ready with `kubectl`: + + ```bash + kubectl get ksvc -n ${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}-preview + ``` + edit-mode: replace diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 8f568a8..9b23805 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -51,7 +51,7 @@ jobs: context: . push: true tags: | - ghcr.io/${{ steps.meta.outputs.tags }} + ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max @@ -78,10 +78,18 @@ jobs: - name: Commit Prod Env Changes run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add . - git commit -m "feat: Promoting ${{ github.event.repository.name }} to ${{ github.ref_name }}" + if output=$(git status --porcelain) && [ -z "$output" ]; then + # Working directory clean + + echo "No changes to commit" + else + # Uncommitted changes + + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add -A + git commit -m "feat: Promoting ${{ github.event.repository.name }} to ${{ github.ref_name }}" + fi - name: Push prod uses: ad-m/github-push-action@master diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0ef67ad..738516b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,30 +5,8 @@ on: - main jobs: - # quality: - # runs-on: ubuntu-latest - - # strategy: - # matrix: - # node-version: [18.x] - # # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - # steps: - # - uses: actions/checkout@v2 - # - name: Use Node.js ${{ matrix.node-version }} - # uses: actions/setup-node@v2 - # with: - # node-version: ${{ matrix.node-version }} - # cache: 'npm' - # - run: npm ci - # - run: npm run lint --if-present - # - run: npm run build --if-present - # - run: npm test - # - run: npx codecov - release: runs-on: ubuntu-latest - # needs: quality permissions: packages: write diff --git a/helm/values.yaml b/helm/values.yaml index 240318b..3b13e44 100755 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -38,7 +38,7 @@ readinessProbe: resources: limits: - cpu: '1' + cpu: "1" memory: 1Gi requests: cpu: 200m @@ -50,7 +50,7 @@ hasura: name: example-hasura-metadata-postgresql database: metadata username: postgres - hostname: + hostname: write: example-hasura-metadata-postgresql read: example-hasura-metadata-postgresql-repl pool: example-hasura-metadata-db-pgpool @@ -106,7 +106,7 @@ readmodel: name: example-readmodel-postgresql database: readmodel username: postgres - hostname: + hostname: write: example-readmodel-postgresql read: example-readmodel-postgresql-repl pool: example-readmodel-pgpool @@ -116,7 +116,7 @@ sourced: name: example-sourced-db-postgresql database: sourced username: postgres - hostname: + hostname: write: example-sourced-db-postgresql read: example-sourced-db-postgresql-repl pool: example-sourced-db-pgpool @@ -126,7 +126,7 @@ web3auth: name: web3auth-db-postgresql database: web3auth username: postgres - hostname: + hostname: write: web3auth-db-postgresql read: web3auth-db-postgresql-repl - pool: web3auth-db-pgpool \ No newline at end of file + pool: web3auth-db-pgpool diff --git a/preview/helm/Chart.yaml b/preview/helm/Chart.yaml new file mode 100644 index 0000000..3ce920d --- /dev/null +++ b/preview/helm/Chart.yaml @@ -0,0 +1,6 @@ +# Helm chart.yaml +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: example-todo-model-service-preview +version: 1.0.0 diff --git a/preview/helm/templates/app.yaml b/preview/helm/templates/app.yaml new file mode 100644 index 0000000..8bd2e2a --- /dev/null +++ b/preview/helm/templates/app.yaml @@ -0,0 +1,29 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: {{ .Values.repository.name }}-{{ .Values.pr }}-preview-app + namespace: argocd + finalizers: + - resources-finalizer.argocd.argoproj.io + annotations: + argocd.argoproj.io/sync-wave: "2" +spec: + project: example-preview-envs + source: + path: helm + repoURL: https://github.com/cloudnativeentrepreneur/{{ .Values.repository.name }}.git + targetRevision: {{ .Values.headRef }} + helm: + version: v3 + values: | + image: + tag: {{ .Values.tag }} + destination: + namespace: {{ .Values.repository.name }}-{{ .Values.pr }}-preview + server: https://kubernetes.default.svc + syncPolicy: + automated: + selfHeal: true + prune: true + syncOptions: + - CreateNamespace=true diff --git a/preview/helm/templates/environment.yaml b/preview/helm/templates/environment.yaml new file mode 100644 index 0000000..653c383 --- /dev/null +++ b/preview/helm/templates/environment.yaml @@ -0,0 +1,23 @@ + +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: {{ .Values.repository.name }}-{{ .Values.pr }}-preview-environment + namespace: argocd + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: example-preview-envs + source: + path: helm + repoURL: https://github.com/cloudnativeentrepreneur/environment.git + targetRevision: v0.2.0 + helm: + version: v3 + destination: + namespace: {{ .Values.repository.name }}-{{ .Values.pr }}-preview + server: https://kubernetes.default.svc + syncPolicy: + automated: + selfHeal: true + prune: true \ No newline at end of file diff --git a/preview/helm/values.yaml b/preview/helm/values.yaml new file mode 100644 index 0000000..79e8db9 --- /dev/null +++ b/preview/helm/values.yaml @@ -0,0 +1,5 @@ +pr: +headRef: +tag: +repository: + name: \ No newline at end of file From cc222e767e445867a9d0777c9a20ccf16425fa9a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 28 Nov 2022 13:54:44 -0600 Subject: [PATCH 097/101] feat: shared workflows (#11) * feat: shared workflows * fix: no node --- .github/workflows/pr-close.yaml | 45 +----- .github/workflows/pr.yaml | 150 ++++-------------- .github/workflows/publish-and-promote.yaml | 116 +++----------- .github/workflows/release.yaml | 92 ++++------- preview/helm/Chart.yaml | 2 +- .../templates/{app.yaml => application.yaml} | 12 +- preview/helm/templates/environment.yaml | 9 +- preview/helm/values.yaml | 11 +- promote/helm/Chart.yaml | 6 + promote/helm/templates/application.yaml | 26 +++ promote/helm/values.yaml | 5 + 11 files changed, 144 insertions(+), 330 deletions(-) rename preview/helm/templates/{app.yaml => application.yaml} (54%) create mode 100644 promote/helm/Chart.yaml create mode 100644 promote/helm/templates/application.yaml create mode 100644 promote/helm/values.yaml diff --git a/.github/workflows/pr-close.yaml b/.github/workflows/pr-close.yaml index cf19868..82ca557 100644 --- a/.github/workflows/pr-close.yaml +++ b/.github/workflows/pr-close.yaml @@ -5,43 +5,8 @@ on: jobs: - pr-close: - runs-on: ubuntu-latest - - permissions: - issues: write - pull-requests: write - contents: write - - steps: - - - name: Checkout Preview Environments Project - uses: actions/checkout@v3 - with: - repository: cloudnativeentrepreneur/example-preview-envs - persist-credentials: false - - - name: Commit Preview Env Changes - run: | - rm helm/templates/${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}.yaml - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add . - git commit -m "remove: ${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}" - - - name: Push Preview Env Changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GH_ORG_TOKEN }} - repository: cloudnativeentrepreneur/example-preview-envs - - - name: Create comment about garbage collection - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - Your preview environment has been removed. It will be garbage collected soon. - - To create a new preview environment, open a new pull request. - edit-mode: replace \ No newline at end of file + preview-cleanup: + uses: CloudNativeEntrepreneur/actions/.github/workflows/gitops-preview-cleanup.yaml@main + secrets: inherit + with: + environment_repository: CloudNativeEntrepreneur/example-preview-envs \ No newline at end of file diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index bdce00d..3e83dee 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -8,120 +8,38 @@ on: jobs: - preview: - runs-on: ubuntu-latest - - permissions: - packages: write - contents: write - issues: write - pull-requests: write - - steps: - - - name: downcase REPO - run: | - echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ env.REPO }} - - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: | - ${{ steps.meta.outputs.tags }} - ghcr.io/${{ env.REPO }}:pr-${{ github.event.pull_request.number }}-${{ github.sha }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache - cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max - - - name: Setup Helm - uses: azure/setup-helm@v3 - - - name: Checkout Preview Environments Project - uses: actions/checkout@v3 - with: - path: previews - repository: cloudnativeentrepreneur/example-preview-envs - persist-credentials: false + helm-quality: + uses: CloudNativeEntrepreneur/actions/.github/workflows/helm-quality.yaml@main + with: + helm_path: helm + + preview-helm-quality: + uses: CloudNativeEntrepreneur/actions/.github/workflows/helm-quality.yaml@main + with: + helm_path: preview/helm + + promote-helm-quality: + uses: CloudNativeEntrepreneur/actions/.github/workflows/helm-quality.yaml@main + with: + helm_path: promote/helm - - name: Create Preview from Helm template - run: | - mkdir -p previews/helm/templates - helm template preview/helm/ \ - --set pr=pr-${{ github.event.pull_request.number }} \ - --set tag=pr-${{ github.event.pull_request.number }}-${{ github.sha }} \ - --set headRef=${{ github.head_ref }} \ - --set repository.name=${{ github.event.repository.name }} \ - > previews/helm/templates/${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}.yaml - - - name: Commit Preview Env Changes - run: | - cd previews - - if output=$(git status --porcelain) && [ -z "$output" ]; then - # Working directory clean - - echo "No changes to commit" - else - # Uncommitted changes - - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add -A - git commit -m "promote: ${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }} ${{ github.sha }}" - fi - - - name: Push Preview Env Changes - uses: ad-m/github-push-action@master - with: - directory: previews - github_token: ${{ secrets.GH_ORG_TOKEN }} - repository: cloudnativeentrepreneur/example-preview-envs - - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: Your preview environment - - - name: Create or update comment - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - Your preview environment has been published! :rocket: - - This service doesn't have a public URL. - - You can verify the PR is ready with `kubectl`: - - ```bash - kubectl get ksvc -n ${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}-preview - ``` - edit-mode: replace + preview: + needs: + - helm-quality + - preview-helm-quality + - promote-helm-quality + uses: CloudNativeEntrepreneur/actions/.github/workflows/gitops-preview.yaml@main + secrets: inherit + with: + container: true + environment_repository: CloudNativeEntrepreneur/example-preview-envs + project: example-preview-envs + comment: | + Your preview environment has been published! :rocket: + + It may take a few minutes to spin up, but you can view it here once it's ready: [${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}-preview](http://${{ github.event.repository.name }}.${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}-preview.127.0.0.1.sslip.io) + + You can verify the PR is ready with `kubectl`: + ```bash + kubectl get ksvc -n ${{ github.event.repository.name }}-pr-${{ github.event.pull_request.number }}-preview + ``` diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 9b23805..1b731d8 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -1,98 +1,30 @@ -name: publish-and-promote +name: promote on: push: tags: - v*.*.* -jobs: - - publish: - runs-on: ubuntu-latest - - permissions: - packages: write - contents: write - - steps: - - - name: downcase REPO - run: | - echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - # - name: use REPO - # run: echo "The value of REPO is: ${{ env.REPO }}" - - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - fetch-depth: 0 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ env.REPO }} - - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: . - push: true - tags: | - ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache - cache-to: type=registry,ref=ghcr.io/${{ env.REPO }}:buildcache,mode=max - - promote: - needs: publish - runs-on: ubuntu-latest - - permissions: - contents: write - - steps: - - name: Checkout production environment - uses: actions/checkout@v3 - with: - repository: cloudnativeentrepreneur/example-prod-env - persist-credentials: false - fetch-depth: 0 - - - name: Update prod environment - uses: mikefarah/yq@master - with: - cmd: yq -i '.spec.source.targetRevision = "${{ github.ref_name }}"' helm/templates/${{ github.event.repository.name }}.yaml - - - name: Commit Prod Env Changes - run: | - if output=$(git status --porcelain) && [ -z "$output" ]; then - # Working directory clean - - echo "No changes to commit" - else - # Uncommitted changes - - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add -A - git commit -m "feat: Promoting ${{ github.event.repository.name }} to ${{ github.ref_name }}" - fi +jobs: - - name: Push prod - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GH_ORG_TOKEN }} - repository: cloudnativeentrepreneur/example-prod-env \ No newline at end of file + publish-container: + uses: CloudNativeEntrepreneur/actions/.github/workflows/publish-container.yaml@main + secrets: inherit + + promote-local: + uses: CloudNativeEntrepreneur/actions/.github/workflows/gitops-promote-helm.yaml@main + secrets: inherit + with: + environment_repository: CloudNativeEntrepreneur/example-local-env + project: example-local-env + pull_request: true + values: | + # Set from promote job of CloudNativeEntrepreneur/example-hasura + local: true + + promote-prod: + uses: CloudNativeEntrepreneur/actions/.github/workflows/gitops-promote-helm.yaml@main + secrets: inherit + with: + environment_repository: CloudNativeEntrepreneur/example-prod-env + project: example-prod-env + pull_request: true diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 738516b..e6e0bcd 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,68 +5,32 @@ on: - main jobs: - release: - runs-on: ubuntu-latest - - permissions: - packages: write - contents: write - - steps: - - - name: downcase REPO - run: | - echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - # - name: use REPO - # run: echo "The value of REPO is: ${{ env.REPO }}" - - - name: Checkout - uses: actions/checkout@v3 - with: - persist-credentials: false - fetch-depth: 0 + helm-quality: + uses: CloudNativeEntrepreneur/actions/.github/workflows/helm-quality.yaml@main + with: + helm_path: helm + + preview-helm-quality: + uses: CloudNativeEntrepreneur/actions/.github/workflows/helm-quality.yaml@main + with: + helm_path: preview/helm + + promote-helm-quality: + uses: CloudNativeEntrepreneur/actions/.github/workflows/helm-quality.yaml@main + with: + helm_path: promote/helm + + node-quality: + uses: CloudNativeEntrepreneur/actions/.github/workflows/node-quality.yaml@main - - name: Application Version - id: version - uses: paulhatch/semantic-version@v4.0.3 - with: - major_pattern: "BREAKING CHANGE" - minor_pattern: "feat:" - bump_each_commit: true - - - name: Build Changelog - id: changelog - uses: mikepenz/release-changelog-builder-action@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Update version in helm values - uses: mikefarah/yq@master - with: - cmd: yq -i '.image.tag = "${{ steps.version.outputs.version_tag }}"' helm/values.yaml - - - name: Update version in helm chart - uses: mikefarah/yq@master - with: - cmd: yq -i '.version = "${{ steps.version.outputs.version_tag }}"' helm/Chart.yaml - - - name: Commit changes - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git commit -am "chore: set version to ${{ steps.version.outputs.version_tag }}" - git tag -a ${{ steps.version.outputs.version_tag }} -m "${{ steps.version.outputs.version_tag }}" - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GH_ORG_TOKEN }} - branch: ${{ steps.version.outputs.version_tag }} - tags: true - - - name: Release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ steps.version.outputs.version_tag }} - generate_release_notes: true - body: ${{steps.changelog.outputs.changelog}} \ No newline at end of file + release: + needs: + - helm-quality + - preview-helm-quality + - promote-helm-quality + - node-quality + uses: CloudNativeEntrepreneur/actions/.github/workflows/github-release.yaml@main + secrets: inherit + with: + helm: true + container: true \ No newline at end of file diff --git a/preview/helm/Chart.yaml b/preview/helm/Chart.yaml index 3ce920d..7587cda 100644 --- a/preview/helm/Chart.yaml +++ b/preview/helm/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v1 appVersion: "1.0" description: A Helm chart for Kubernetes -name: example-todo-model-service-preview +name: example-hasura version: 1.0.0 diff --git a/preview/helm/templates/app.yaml b/preview/helm/templates/application.yaml similarity index 54% rename from preview/helm/templates/app.yaml rename to preview/helm/templates/application.yaml index 8bd2e2a..5196775 100644 --- a/preview/helm/templates/app.yaml +++ b/preview/helm/templates/application.yaml @@ -1,17 +1,15 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: {{ .Values.repository.name }}-{{ .Values.pr }}-preview-app + name: {{ .Values.name }}-{{ .Values.pr }}-preview-app namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io - annotations: - argocd.argoproj.io/sync-wave: "2" spec: - project: example-preview-envs + project: {{ .Values.project }} source: path: helm - repoURL: https://github.com/cloudnativeentrepreneur/{{ .Values.repository.name }}.git + repoURL: https://github.com/{{ .Values.repository }}.git targetRevision: {{ .Values.headRef }} helm: version: v3 @@ -19,11 +17,9 @@ spec: image: tag: {{ .Values.tag }} destination: - namespace: {{ .Values.repository.name }}-{{ .Values.pr }}-preview + namespace: {{ .Values.name }}-{{ .Values.pr }}-preview server: https://kubernetes.default.svc syncPolicy: automated: selfHeal: true prune: true - syncOptions: - - CreateNamespace=true diff --git a/preview/helm/templates/environment.yaml b/preview/helm/templates/environment.yaml index 653c383..abc6aea 100644 --- a/preview/helm/templates/environment.yaml +++ b/preview/helm/templates/environment.yaml @@ -1,21 +1,22 @@ - apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: {{ .Values.repository.name }}-{{ .Values.pr }}-preview-environment + name: {{ .Values.name }}-{{ .Values.pr }}-preview-environment namespace: argocd finalizers: - resources-finalizer.argocd.argoproj.io + annotations: + argocd.argoproj.io/sync-wave: "-1" spec: project: example-preview-envs source: path: helm repoURL: https://github.com/cloudnativeentrepreneur/environment.git - targetRevision: v0.2.0 + targetRevision: v0.4.0 helm: version: v3 destination: - namespace: {{ .Values.repository.name }}-{{ .Values.pr }}-preview + namespace: {{ .Values.name }}-{{ .Values.pr }}-preview server: https://kubernetes.default.svc syncPolicy: automated: diff --git a/preview/helm/values.yaml b/preview/helm/values.yaml index 79e8db9..e576bb1 100644 --- a/preview/helm/values.yaml +++ b/preview/helm/values.yaml @@ -1,5 +1,6 @@ -pr: -headRef: -tag: -repository: - name: \ No newline at end of file +name: example-hasura +pr: pr-0 +headRef: HEAD +tag: latest +repository: CloudNativeEntrepreneur/example-hasura +project: dev \ No newline at end of file diff --git a/promote/helm/Chart.yaml b/promote/helm/Chart.yaml new file mode 100644 index 0000000..924155e --- /dev/null +++ b/promote/helm/Chart.yaml @@ -0,0 +1,6 @@ +# Helm chart.yaml +apiVersion: v1 +appVersion: "1.0" +description: Config to promote +name: example-hasura-promote +version: v0.0.0-dev diff --git a/promote/helm/templates/application.yaml b/promote/helm/templates/application.yaml new file mode 100644 index 0000000..0459ca5 --- /dev/null +++ b/promote/helm/templates/application.yaml @@ -0,0 +1,26 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: {{ .Values.name }} + namespace: argocd + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: {{ .Values.project }} + source: + path: helm + repoURL: https://github.com/{{ .Values.repository }}.git + targetRevision: {{ .Values.version }} + helm: + version: v3 +{{- if .Values.values }} + values: | + {{ .Values.values | nindent 8 }} +{{- end }} + destination: + namespace: {{ .Values.project }} + server: https://kubernetes.default.svc + syncPolicy: + automated: + selfHeal: true + prune: true diff --git a/promote/helm/values.yaml b/promote/helm/values.yaml new file mode 100644 index 0000000..1c04e21 --- /dev/null +++ b/promote/helm/values.yaml @@ -0,0 +1,5 @@ +name: example-hasura +version: HEAD +project: dev +repository: CloudNativeEntrepreneur/example-hasura +values: "" \ No newline at end of file From 355611906c0f13a2a853868dcc2d216a95f15a2d Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 28 Nov 2022 14:57:17 -0500 Subject: [PATCH 098/101] fix: no node --- .github/workflows/release.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e6e0bcd..8b7dad5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,15 +20,11 @@ jobs: with: helm_path: promote/helm - node-quality: - uses: CloudNativeEntrepreneur/actions/.github/workflows/node-quality.yaml@main - release: needs: - helm-quality - preview-helm-quality - promote-helm-quality - - node-quality uses: CloudNativeEntrepreneur/actions/.github/workflows/github-release.yaml@main secrets: inherit with: From 30bfdf2f2588fdb1e806631494c441fb25d13052 Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 28 Nov 2022 15:09:01 -0500 Subject: [PATCH 099/101] fix: auto-promote --- .github/workflows/publish-and-promote.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-and-promote.yaml b/.github/workflows/publish-and-promote.yaml index 1b731d8..5abfe5e 100644 --- a/.github/workflows/publish-and-promote.yaml +++ b/.github/workflows/publish-and-promote.yaml @@ -16,7 +16,7 @@ jobs: with: environment_repository: CloudNativeEntrepreneur/example-local-env project: example-local-env - pull_request: true + pull_request: false values: | # Set from promote job of CloudNativeEntrepreneur/example-hasura local: true @@ -27,4 +27,4 @@ jobs: with: environment_repository: CloudNativeEntrepreneur/example-prod-env project: example-prod-env - pull_request: true + pull_request: false From 244cd86746422a7a42c6a7daf00b459e5fbd585a Mon Sep 17 00:00:00 2001 From: Patrick Lee Scott Date: Mon, 28 Nov 2022 15:14:27 -0500 Subject: [PATCH 100/101] fix(renovate): argocd --- renovate.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/renovate.json b/renovate.json index 872f5da..2236ea0 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,9 @@ { "extends": ["config:base"], - "prConcurrentLimit": 0, - "prHourlyLimit": 0, - "rebaseWhen": "behind-base-branch" + "argocd": { + "fileMatch": [ + "preview/helm/templates/.+\\.yaml$", + "promote/helm/templates/.+\\.yaml$" + ] + } } From 4a997d4d1971615aadb1b525d6e24b1f3378af5a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 28 May 2023 09:21:19 +0000 Subject: [PATCH 101/101] chore(deps): update hasura/graphql-engine docker tag to v2.25.1 --- docker-compose.default-example.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.default-example.yaml b/docker-compose.default-example.yaml index 0d51713..4a375f7 100644 --- a/docker-compose.default-example.yaml +++ b/docker-compose.default-example.yaml @@ -8,7 +8,7 @@ services: environment: POSTGRES_PASSWORD: postgrespassword graphql-engine: - image: hasura/graphql-engine:v2.14.0 + image: hasura/graphql-engine:v2.25.1 ports: - "8080:8080" depends_on: