From 269649e63ffe03a78077aed1f4d39bf6a0d55b4b Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 14:10:21 +0200 Subject: [PATCH 01/12] Use shared GH WF for PRs --- .github/workflows/pull-request.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a7a7b36..0555495 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,10 +4,13 @@ on: pull_request: branches: [ master ] +env: + GH_WORKFLOWS: aeternity/github-actions/.github/workflows + jobs: validate: - uses: ./.github/workflows/_validate.yml + uses: $GH_WORKFLOWS/_validate-npm.yml@master publish: - uses: ./.github/workflows/_publish.yml + uses: $GH_WORKFLOWS/_publish.yml@master needs: [ validate ] secrets: inherit From f021ad0771a196387a3f9d6658b43ed4a80ece7e Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 14:14:13 +0200 Subject: [PATCH 02/12] Don't use env vars --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 0555495..9be5e88 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -9,8 +9,8 @@ env: jobs: validate: - uses: $GH_WORKFLOWS/_validate-npm.yml@master + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master publish: - uses: $GH_WORKFLOWS/_publish.yml@master + uses: aeternity/github-actions/.github/workflows/_publish.yml@master needs: [ validate ] secrets: inherit From 86e2ea4bada024b276cf909a2aa297ee81a5d84d Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 14:20:12 +0200 Subject: [PATCH 03/12] Fix publish WF name --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9be5e88..3d4f017 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,6 +11,6 @@ jobs: validate: uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master publish: - uses: aeternity/github-actions/.github/workflows/_publish.yml@master + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master needs: [ validate ] secrets: inherit From c0ca439afc19e9df7ef76e341a10787b67d121d7 Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 14:24:32 +0200 Subject: [PATCH 04/12] Try env context --- .github/workflows/pull-request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3d4f017..34c39c9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -9,8 +9,8 @@ env: jobs: validate: - uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master + uses: ${{ env.GH_WORKFLOWS }}/_validate-npm.yml@master publish: - uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master + uses: ${{ env.GH_WORKFLOWS }}/_publish-docker.yml@master needs: [ validate ] secrets: inherit From bbfa39654b32e1847f81b1a2fb4b9a95a41dc137 Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 14:40:24 +0200 Subject: [PATCH 05/12] Switch all WFs to shared --- .github/workflows/_deploy.yml | 82 ------------------------------ .github/workflows/_publish.yml | 37 -------------- .github/workflows/_validate.yml | 20 -------- .github/workflows/mainline.yml | 6 +-- .github/workflows/pull-request.yml | 7 +-- .github/workflows/release.yml | 6 +-- 6 files changed, 8 insertions(+), 150 deletions(-) delete mode 100644 .github/workflows/_deploy.yml delete mode 100644 .github/workflows/_publish.yml delete mode 100644 .github/workflows/_validate.yml diff --git a/.github/workflows/_deploy.yml b/.github/workflows/_deploy.yml deleted file mode 100644 index ec66d0a..0000000 --- a/.github/workflows/_deploy.yml +++ /dev/null @@ -1,82 +0,0 @@ -on: - workflow_call: - inputs: - DEPLOY_REPO: - description: 'Gitops repository used to deploy' - type: string - default: aeternity/gitops-apps - DEPLOY_APP: - description: 'Deploy application in gitops repository, usually the caller repository name' - type: string - default: ${{ github.event.repository.name }} - DEPLOY_ENV: - description: 'Deploy environment name to deploy to' - type: string - required: true - DEPLOY_VERSION: - description: 'Application version to deploy' - type: string - required: false - DEPLOY_TAG: - description: 'Application tag to deploy' - type: string - required: false - DEPLOY_HOST_PREFIX: - description: 'Deployment hostname prefix, usually $VERSION-' - type: string - required: false - -jobs: - deploy: - name: "Deploy to Gitops" - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - with: - repository: ${{ inputs.DEPLOY_REPO }} - token: ${{ secrets.BOT_GITHUB_TOKEN }} - ref: ${{ inputs.DEPLOY_ENV }} - persist-credentials: false - fetch-depth: 0 - - - name: Configure git - shell: bash - run: | - git config --local user.email "aeternity-bot@users.noreply.github.com" - git config --local user.name "github-actions" - - - name: Update application version in Gitops repository - if: ${{ inputs.DEPLOY_VERSION != '' }} - shell: bash - env: - APP_ENV: ${{ inputs.DEPLOY_ENV }} - APP_VERSION: ${{ inputs.DEPLOY_VERSION }} - APP_HOST_PREFIX: ${{ inputs.DEPLOY_HOST_PREFIX }} - APP_VERSION_SHA_LONG: ${{ github.sha }} - run: | - export APP_VERSION_SHA=${APP_VERSION_SHA_LONG:0:7} - ./scripts/app.sh update-version ${{ inputs.DEPLOY_APP }} - - - name: Update application tag in Gitops repository - if: ${{ inputs.DEPLOY_TAG != '' }} - shell: bash - env: - APP_ENV: ${{ inputs.DEPLOY_ENV }} - APP_VERSION: ${{ inputs.DEPLOY_TAG }} - run: | - ./scripts/app.sh update-tag ${{ inputs.DEPLOY_APP }} - - - name: Commit Gitops changes - shell: bash - env: - APP_VERSION: ${{ inputs.DEPLOY_TAG || inputs.DEPLOY_VERSION }} - run: | - git add . - git commit -m "Deploy ${{ inputs.DEPLOY_APP }} to ${{ inputs.DEPLOY_ENV }} - ${APP_VERSION} (sha: ${{ github.sha }})" - - - name: Push changes - uses: ad-m/github-push-action@master - with: - repository: ${{ inputs.DEPLOY_REPO }} - github_token: ${{ secrets.BOT_GITHUB_TOKEN }} - branch: ${{ inputs.DEPLOY_ENV }} diff --git a/.github/workflows/_publish.yml b/.github/workflows/_publish.yml deleted file mode 100644 index 78cc3d4..0000000 --- a/.github/workflows/_publish.yml +++ /dev/null @@ -1,37 +0,0 @@ -on: - workflow_call: - secrets: - DOCKERHUB_USER: - required: true - DOCKERHUB_PASS: - required: true - -jobs: - dockerhub: - name: "Publish to Dockehub" - runs-on: ubuntu-20.04 - steps: - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: | - ${{ github.repository }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - - - name: Login to Dockerhub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_PASS }} - - - name: Build and push docker image - uses: docker/build-push-action@v4 - if: ${{ steps.meta.outputs.tags }} - with: - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/_validate.yml b/.github/workflows/_validate.yml deleted file mode 100644 index aa4584e..0000000 --- a/.github/workflows/_validate.yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - workflow_call: - -jobs: - build_test: - runs-on: ubuntu-20.04 - strategy: - matrix: - node-version: [18.x] - steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: npm - - run: npm config set fund false - - run: npm install - - run: npm run lint - - run: npm run test diff --git a/.github/workflows/mainline.yml b/.github/workflows/mainline.yml index 50efe1f..f5a216d 100644 --- a/.github/workflows/mainline.yml +++ b/.github/workflows/mainline.yml @@ -6,13 +6,13 @@ on: jobs: validate: - uses: ./.github/workflows/_validate.yml + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml publish: - uses: ./.github/workflows/_publish.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml needs: [ validate ] secrets: inherit deploy: - uses: ./.github/workflows/_deploy.yml + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml needs: [publish] secrets: inherit strategy: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 34c39c9..96ad918 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -4,13 +4,10 @@ on: pull_request: branches: [ master ] -env: - GH_WORKFLOWS: aeternity/github-actions/.github/workflows - jobs: validate: - uses: ${{ env.GH_WORKFLOWS }}/_validate-npm.yml@master + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master publish: - uses: ${{ env.GH_WORKFLOWS }}/_publish-docker.yml@master + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master needs: [ validate ] secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ef9a98..28773e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,13 +6,13 @@ on: jobs: validate: - uses: ./.github/workflows/_validate.yml + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master publish: - uses: ./.github/workflows/_publish.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master needs: [ validate ] secrets: inherit deploy: - uses: ./.github/workflows/_deploy.yml + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@master needs: [publish] secrets: inherit strategy: From 5500d8107a2d4ab004e54339e579614995978a8e Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 14:48:15 +0200 Subject: [PATCH 06/12] Test deployment pipeline --- .github/workflows/pull-request.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 96ad918..c72e4bf 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,3 +11,15 @@ jobs: uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master needs: [ validate ] secrets: inherit + deploy: + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@master + needs: [publish] + secrets: inherit + strategy: + max-parallel: 1 + matrix: + flavor: [testnet, mainnet] + with: + DEPLOY_ENV: dev + DEPLOY_APP: "${{ github.event.repository.name }}-${{ matrix.flavor }}" + DEPLOY_VERSION: "pr-${{ github.event.number }}" From ef2df27dca71003577da7e0eb32d0fcfc0a57ed9 Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 15:07:30 +0200 Subject: [PATCH 07/12] Add host prefix --- .github/workflows/pull-request.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index c72e4bf..6c72cbb 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -23,3 +23,4 @@ jobs: DEPLOY_ENV: dev DEPLOY_APP: "${{ github.event.repository.name }}-${{ matrix.flavor }}" DEPLOY_VERSION: "pr-${{ github.event.number }}" + APP_HOST_PREFIX: "pr-${{ github.event.number }}" From f7e08c0ee4952741ba317a3a73fe1b919299f762 Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Tue, 7 Nov 2023 15:15:27 +0200 Subject: [PATCH 08/12] Fix deploy var name --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6c72cbb..d77c139 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -23,4 +23,4 @@ jobs: DEPLOY_ENV: dev DEPLOY_APP: "${{ github.event.repository.name }}-${{ matrix.flavor }}" DEPLOY_VERSION: "pr-${{ github.event.number }}" - APP_HOST_PREFIX: "pr-${{ github.event.number }}" + DEPLOY_HOST_PREFIX: "pr-${{ github.event.number }}" From db27a4165ba9b27f254625d0741ed7788a85bc0d Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Thu, 9 Nov 2023 15:01:41 +0200 Subject: [PATCH 09/12] Cleanup PR pipeline --- .github/workflows/pull-request.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index d77c139..2643dba 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,20 +7,3 @@ on: jobs: validate: uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master - publish: - uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master - needs: [ validate ] - secrets: inherit - deploy: - uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@master - needs: [publish] - secrets: inherit - strategy: - max-parallel: 1 - matrix: - flavor: [testnet, mainnet] - with: - DEPLOY_ENV: dev - DEPLOY_APP: "${{ github.event.repository.name }}-${{ matrix.flavor }}" - DEPLOY_VERSION: "pr-${{ github.event.number }}" - DEPLOY_HOST_PREFIX: "pr-${{ github.event.number }}" From bdebe7a9d6116a1d8e48c61f92acdf4ce0b66a7a Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Thu, 9 Nov 2023 15:06:31 +0200 Subject: [PATCH 10/12] Change shared GHA WF version --- .github/workflows/mainline.yml | 6 +++--- .github/workflows/pull-request.yml | 2 +- .github/workflows/release.yml | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/mainline.yml b/.github/workflows/mainline.yml index f5a216d..fd406dd 100644 --- a/.github/workflows/mainline.yml +++ b/.github/workflows/mainline.yml @@ -6,13 +6,13 @@ on: jobs: validate: - uses: aeternity/github-actions/.github/workflows/_validate-npm.yml + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@v1.0.0 publish: - uses: aeternity/github-actions/.github/workflows/_publish-docker.yml + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v1.0.0 needs: [ validate ] secrets: inherit deploy: - uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@v1.0.0 needs: [publish] secrets: inherit strategy: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 2643dba..f32aa96 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -6,4 +6,4 @@ on: jobs: validate: - uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@v1.0.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 28773e7..cf6c62f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,13 +6,13 @@ on: jobs: validate: - uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@master + uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@v1.0.0 publish: - uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@master + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v1.0.0 needs: [ validate ] secrets: inherit deploy: - uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@master + uses: aeternity/github-actions/.github/workflows/_deploy-gitops.yml@v1.0.0 needs: [publish] secrets: inherit strategy: From 4008ace2b0ca8a9e7fbcf425b02b3bd6a930dc67 Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Thu, 9 Nov 2023 15:12:07 +0200 Subject: [PATCH 11/12] Add back publish to PR pipeline --- .github/workflows/pull-request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f32aa96..b082697 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,3 +7,7 @@ on: jobs: validate: uses: aeternity/github-actions/.github/workflows/_validate-npm.yml@v1.0.0 + publish: + uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v1.0.0 + needs: [ validate ] + secrets: inherit From 812c6004921e84daa6dbee3b4fd717f1a7cd88dc Mon Sep 17 00:00:00 2001 From: Dincho Todorov Date: Thu, 9 Nov 2023 15:14:56 +0200 Subject: [PATCH 12/12] Add PR cleanup pipeline --- .github/workflows/pull-request-cleanup.yml | 14 ++++++++++++++ .github/workflows/pull-request.yml | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 .github/workflows/pull-request-cleanup.yml diff --git a/.github/workflows/pull-request-cleanup.yml b/.github/workflows/pull-request-cleanup.yml new file mode 100644 index 0000000..9545fd6 --- /dev/null +++ b/.github/workflows/pull-request-cleanup.yml @@ -0,0 +1,14 @@ +name: "Pull Request Cleanup" + +on: + pull_request: + branches: [ master ] + types: [ closed ] + +jobs: + delete-tag: + uses: aeternity/github-actions/.github/workflows/_delete-tag-docker.yml@v1.0.0 + secrets: inherit + with: + DOCKERHUB_REPO: aeternitybot/aemon + DOCKERHUB_TAG: "pr-${{ github.event.number }}" diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index b082697..bddfa6e 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,3 +11,5 @@ jobs: uses: aeternity/github-actions/.github/workflows/_publish-docker.yml@v1.0.0 needs: [ validate ] secrets: inherit + with: + DOCKERHUB_REPO: aeternitybot/aemon