From d7227295ebdfc2155f7b089c435f22713f79bb43 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Thu, 7 Dec 2023 14:47:30 +0200 Subject: [PATCH 01/10] make bump version script be triggered by workflow_dispatch instead of cron Signed-off-by: Ronny Orot --- .github/workflows/bump-versions.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bump-versions.yml b/.github/workflows/bump-versions.yml index 03ec7137d5..04428a2f65 100644 --- a/.github/workflows/bump-versions.yml +++ b/.github/workflows/bump-versions.yml @@ -1,15 +1,21 @@ name: Bump Provider and Module Versions on: - schedule: - - cron: '5 * * * *' workflow_dispatch: + inputs: + environment: + type: choice + description: The environment of the Registry + options: + - Development + - Production jobs: bump-versions: runs-on: ubuntu-latest - environment: Development + environment: + name: ${{ inputs.environment }} permissions: contents: write actions: write @@ -31,9 +37,4 @@ jobs: - uses: stefanzweifel/git-auto-commit-action@v5 with: file_pattern: 'modules/**/* providers/**/*' - commit_user_name: Auto Version Bumper - - - name: Invoke publish workflow - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: generate-and-deploy.yml + commit_user_name: Auto Version Bumper \ No newline at end of file From 6721ed34f00a2baa889025496b331f355a8691c6 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Thu, 7 Dec 2023 14:48:45 +0200 Subject: [PATCH 02/10] Change publish script to get the environment as a parameter Signed-off-by: Ronny Orot --- .../workflows/generate-and-deploy-with-delete.yml | 13 ++++++++++--- .github/workflows/generate-and-deploy.yml | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/generate-and-deploy-with-delete.yml b/.github/workflows/generate-and-deploy-with-delete.yml index 22be50be42..edf121158a 100644 --- a/.github/workflows/generate-and-deploy-with-delete.yml +++ b/.github/workflows/generate-and-deploy-with-delete.yml @@ -2,13 +2,20 @@ name: Generate and Sync Files with Delete on: - workflow_dispatch + workflow_dispatch: + inputs: + environment: + type: choice + description: The environment of the Registry + options: + - Development-with-delete + - Production-with-delete jobs: generate-and-sync: runs-on: ubuntu-latest - - environment: Production-with-delete + environment: + name: ${{ inputs.environment }} steps: - name: Checkout Repository diff --git a/.github/workflows/generate-and-deploy.yml b/.github/workflows/generate-and-deploy.yml index f47ee558d9..dce4e13c25 100644 --- a/.github/workflows/generate-and-deploy.yml +++ b/.github/workflows/generate-and-deploy.yml @@ -2,13 +2,20 @@ name: Generate and Sync Files on: - workflow_dispatch + workflow_dispatch: + inputs: + environment: + type: choice + description: The environment of the Registry + options: + - Development + - Production jobs: generate-and-sync: runs-on: ubuntu-latest - - environment: Production + environment: + name: ${{ inputs.environment }} steps: - name: Checkout Repository From 73bd04e5aba0334d3ee21121659ec55d2dfb73a7 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Thu, 7 Dec 2023 14:49:14 +0200 Subject: [PATCH 03/10] Add WF to trigger production Signed-off-by: Ronny Orot --- .../bump-and-publish-versions-prod.yml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/bump-and-publish-versions-prod.yml diff --git a/.github/workflows/bump-and-publish-versions-prod.yml b/.github/workflows/bump-and-publish-versions-prod.yml new file mode 100644 index 0000000000..6c6c65eec5 --- /dev/null +++ b/.github/workflows/bump-and-publish-versions-prod.yml @@ -0,0 +1,20 @@ +name: Bump Versions and Publish - Prod + +on: + schedule: + - cron: '5 * * * *' + workflow_dispatch: + +jobs: + bump-versions: + uses: opentofu/registry/.github/workflows/bump-versions.yml@main + secrets: inherit + with: + environment: "Production" + + publish-versions: + needs: bump-versions + uses: opentofu/registry/.github/workflows/generate-and-deploy.yml@main + secrets: inherit + with: + environment: "Production" \ No newline at end of file From 64645b36a16a7c742a3621b1384eb83f94242023 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Thu, 7 Dec 2023 15:38:49 +0200 Subject: [PATCH 04/10] push updated files to a new branch on dev Signed-off-by: Ronny Orot --- .github/workflows/bump-versions.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bump-versions.yml b/.github/workflows/bump-versions.yml index 04428a2f65..cbfb34fb7d 100644 --- a/.github/workflows/bump-versions.yml +++ b/.github/workflows/bump-versions.yml @@ -34,7 +34,19 @@ jobs: working-directory: ./src run: go run ./cmd/bump-versions + - name: Get branch + run: | + if [ "${{ inputs.environment }}" = "Production" ]; then + export BRANCH="${{ github.ref }}" + elif [ "${{ inputs.environment }}" = "Development" ]; then + TIMESTAMP=$(date +%s) + export BRANCH="${{ github.ref }}-bump-versions-$TIMESTAMP" + fi + echo "BRANCH=$BRANCH" >> $GITHUB_ENV + - uses: stefanzweifel/git-auto-commit-action@v5 with: file_pattern: 'modules/**/* providers/**/*' - commit_user_name: Auto Version Bumper \ No newline at end of file + commit_user_name: Auto Version Bumper + branch: ${{ env.BRANCH }} + create_branch: true \ No newline at end of file From 3b7c05e7fdf81b75ef1a093a9167d5799ca0d2f0 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Mon, 11 Dec 2023 09:00:36 +0200 Subject: [PATCH 05/10] add workflow_call trigger Signed-off-by: Ronny Orot --- .github/workflows/bump-versions.yml | 5 +++++ .github/workflows/generate-and-deploy.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/bump-versions.yml b/.github/workflows/bump-versions.yml index cbfb34fb7d..55d4ac8ba0 100644 --- a/.github/workflows/bump-versions.yml +++ b/.github/workflows/bump-versions.yml @@ -9,6 +9,11 @@ on: options: - Development - Production + workflow_call: + inputs: + environment: + type: string + description: The environment of the Registry jobs: bump-versions: diff --git a/.github/workflows/generate-and-deploy.yml b/.github/workflows/generate-and-deploy.yml index dce4e13c25..f2f72fd930 100644 --- a/.github/workflows/generate-and-deploy.yml +++ b/.github/workflows/generate-and-deploy.yml @@ -10,6 +10,11 @@ on: options: - Development - Production + workflow_call: + inputs: + environment: + type: string + description: The environment of the Registry jobs: generate-and-sync: From 332e27d38500765fa87bde52fe4d09bf677076f8 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Mon, 11 Dec 2023 17:41:44 +0200 Subject: [PATCH 06/10] print the bump-versions branch Signed-off-by: Ronny Orot --- .github/workflows/bump-versions.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bump-versions.yml b/.github/workflows/bump-versions.yml index 55d4ac8ba0..eb8d881278 100644 --- a/.github/workflows/bump-versions.yml +++ b/.github/workflows/bump-versions.yml @@ -40,6 +40,7 @@ jobs: run: go run ./cmd/bump-versions - name: Get branch + id: get-branch run: | if [ "${{ inputs.environment }}" = "Production" ]; then export BRANCH="${{ github.ref }}" @@ -54,4 +55,8 @@ jobs: file_pattern: 'modules/**/* providers/**/*' commit_user_name: Auto Version Bumper branch: ${{ env.BRANCH }} - create_branch: true \ No newline at end of file + create_branch: true + + - name: Print Branch name + run: | + echo "Providers and modules changes were pushed to branch: ${{ env.BRANCH }}" \ No newline at end of file From 4890f240e00865a90fbdc2ef7e679f4114ac98d9 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Mon, 11 Dec 2023 19:00:21 +0200 Subject: [PATCH 07/10] get bump-versions-branch as an input Signed-off-by: Ronny Orot --- .../generate-and-deploy-with-delete.yml | 34 +++++++++++++++---- .github/workflows/generate-and-deploy.yml | 30 +++++++++++++--- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/.github/workflows/generate-and-deploy-with-delete.yml b/.github/workflows/generate-and-deploy-with-delete.yml index edf121158a..8642bf069b 100644 --- a/.github/workflows/generate-and-deploy-with-delete.yml +++ b/.github/workflows/generate-and-deploy-with-delete.yml @@ -8,8 +8,12 @@ on: type: choice description: The environment of the Registry options: - - Development-with-delete - - Production-with-delete + - Development + - Production + bump-versions-branch: + type: string + description: The branch with the modules and providers to publish (if not specified will use the workflow's ref) + required: false jobs: generate-and-sync: @@ -20,20 +24,38 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + path: main + + - name: Checkout branch with modules and providers + if: inputs.bump-versions-branch != '' + uses: actions/checkout@v4 + with: + ref: ${{ inputs.bump-versions-branch }} + path: providers-and-modules - name: Set up Go uses: actions/setup-go@v4 with: - go-version-file: './src/go.mod' + go-version-file: './main/src/go.mod' - name: Setup dependencies run: sudo apt-get install rclone - name: Run Generation script - working-directory: ./src - run: go run ./cmd/generate-v1 --destination ../generated + working-directory: ./main/src + run: | + PATH_PREFIX="../../providers-and-modules" + + if [ -z "${{ inputs.bump-versions-branch }}" ]; then + DATA_DIR_FLAGS="" + else + DATA_DIR_FLAGS="--module-data $PATH_PREFIX/modules --provider-data $PATH_PREFIX/providers --key-data $PATH_PREFIX/keys" + fi + + go run ./cmd/generate-v1 --destination ../../generated $DATA_DIR_FLAGS env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} - name: Sync Data to R2 run: rclone sync --checkers=512 --transfers=512 --checksum --fast-list ./generated R2:${{ secrets.R2_BUCKET_NAME }} diff --git a/.github/workflows/generate-and-deploy.yml b/.github/workflows/generate-and-deploy.yml index f2f72fd930..a3c73f8afd 100644 --- a/.github/workflows/generate-and-deploy.yml +++ b/.github/workflows/generate-and-deploy.yml @@ -10,6 +10,10 @@ on: options: - Development - Production + bump-versions-branch: + type: string + description: The branch with the modules and providers to publish (if not specified will use the workflow's ref) + required: false workflow_call: inputs: environment: @@ -25,20 +29,38 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + path: main + + - name: Checkout branch with modules and providers + if: inputs.bump-versions-branch != '' + uses: actions/checkout@v4 + with: + ref: ${{ inputs.bump-versions-branch }} + path: providers-and-modules - name: Set up Go uses: actions/setup-go@v4 with: - go-version-file: './src/go.mod' + go-version-file: './main/src/go.mod' - name: Setup dependencies run: sudo apt-get install rclone - name: Run Generation script - working-directory: ./src - run: go run ./cmd/generate-v1 --destination ../generated + working-directory: ./main/src + run: | + PATH_PREFIX="../../providers-and-modules" + + if [ -z "${{ inputs.bump-versions-branch }}" ]; then + DATA_DIR_FLAGS="" + else + DATA_DIR_FLAGS="--module-data $PATH_PREFIX/modules --provider-data $PATH_PREFIX/providers --key-data $PATH_PREFIX/keys" + fi + + go run ./cmd/generate-v1 --destination ../../generated $DATA_DIR_FLAGS env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} + GH_TOKEN: ${{ secrets.GH_TOKEN }} - name: Sync Data to R2 run: rclone sync --checkers=512 --transfers=512 --checksum --fast-list --max-delete 0 --delete-after ./generated R2:${{ secrets.R2_BUCKET_NAME }} From bd0e4cb3b9d3e0f2f0931cefe6e207d82b24104d Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Tue, 12 Dec 2023 14:18:43 +0200 Subject: [PATCH 08/10] change the folder name of the checked out code to 'repo' Signed-off-by: Ronny Orot --- .github/workflows/generate-and-deploy-with-delete.yml | 6 +++--- .github/workflows/generate-and-deploy.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/generate-and-deploy-with-delete.yml b/.github/workflows/generate-and-deploy-with-delete.yml index 8642bf069b..47d57ed06f 100644 --- a/.github/workflows/generate-and-deploy-with-delete.yml +++ b/.github/workflows/generate-and-deploy-with-delete.yml @@ -25,7 +25,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: - path: main + path: repo - name: Checkout branch with modules and providers if: inputs.bump-versions-branch != '' @@ -37,13 +37,13 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version-file: './main/src/go.mod' + go-version-file: './repo/src/go.mod' - name: Setup dependencies run: sudo apt-get install rclone - name: Run Generation script - working-directory: ./main/src + working-directory: ./repo/src run: | PATH_PREFIX="../../providers-and-modules" diff --git a/.github/workflows/generate-and-deploy.yml b/.github/workflows/generate-and-deploy.yml index a3c73f8afd..59a7e3737a 100644 --- a/.github/workflows/generate-and-deploy.yml +++ b/.github/workflows/generate-and-deploy.yml @@ -30,7 +30,7 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 with: - path: main + path: repo - name: Checkout branch with modules and providers if: inputs.bump-versions-branch != '' @@ -42,13 +42,13 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version-file: './main/src/go.mod' + go-version-file: './repo/src/go.mod' - name: Setup dependencies run: sudo apt-get install rclone - name: Run Generation script - working-directory: ./main/src + working-directory: ./repo/src run: | PATH_PREFIX="../../providers-and-modules" From 7466e387679b02d64217b648b7af4c52fe6b2d61 Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Tue, 12 Dec 2023 17:24:44 +0200 Subject: [PATCH 09/10] use modules and providers from WF branch Signed-off-by: Ronny Orot --- .../generate-and-deploy-with-delete.yml | 32 +++---------------- .github/workflows/generate-and-deploy.yml | 28 ++-------------- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/.github/workflows/generate-and-deploy-with-delete.yml b/.github/workflows/generate-and-deploy-with-delete.yml index 47d57ed06f..1c5784ea6a 100644 --- a/.github/workflows/generate-and-deploy-with-delete.yml +++ b/.github/workflows/generate-and-deploy-with-delete.yml @@ -8,12 +8,8 @@ on: type: choice description: The environment of the Registry options: - - Development - - Production - bump-versions-branch: - type: string - description: The branch with the modules and providers to publish (if not specified will use the workflow's ref) - required: false + - Development-with-delete + - Production-with-delete jobs: generate-and-sync: @@ -24,36 +20,18 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - with: - path: repo - - - name: Checkout branch with modules and providers - if: inputs.bump-versions-branch != '' - uses: actions/checkout@v4 - with: - ref: ${{ inputs.bump-versions-branch }} - path: providers-and-modules - name: Set up Go uses: actions/setup-go@v4 with: - go-version-file: './repo/src/go.mod' + go-version-file: './src/go.mod' - name: Setup dependencies run: sudo apt-get install rclone - name: Run Generation script - working-directory: ./repo/src - run: | - PATH_PREFIX="../../providers-and-modules" - - if [ -z "${{ inputs.bump-versions-branch }}" ]; then - DATA_DIR_FLAGS="" - else - DATA_DIR_FLAGS="--module-data $PATH_PREFIX/modules --provider-data $PATH_PREFIX/providers --key-data $PATH_PREFIX/keys" - fi - - go run ./cmd/generate-v1 --destination ../../generated $DATA_DIR_FLAGS + working-directory: ./src + run: go run ./cmd/generate-v1 --destination ../generated env: GH_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.github/workflows/generate-and-deploy.yml b/.github/workflows/generate-and-deploy.yml index 59a7e3737a..b5f4c330d7 100644 --- a/.github/workflows/generate-and-deploy.yml +++ b/.github/workflows/generate-and-deploy.yml @@ -10,10 +10,6 @@ on: options: - Development - Production - bump-versions-branch: - type: string - description: The branch with the modules and providers to publish (if not specified will use the workflow's ref) - required: false workflow_call: inputs: environment: @@ -29,36 +25,18 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - with: - path: repo - - - name: Checkout branch with modules and providers - if: inputs.bump-versions-branch != '' - uses: actions/checkout@v4 - with: - ref: ${{ inputs.bump-versions-branch }} - path: providers-and-modules - name: Set up Go uses: actions/setup-go@v4 with: - go-version-file: './repo/src/go.mod' + go-version-file: './src/go.mod' - name: Setup dependencies run: sudo apt-get install rclone - name: Run Generation script - working-directory: ./repo/src - run: | - PATH_PREFIX="../../providers-and-modules" - - if [ -z "${{ inputs.bump-versions-branch }}" ]; then - DATA_DIR_FLAGS="" - else - DATA_DIR_FLAGS="--module-data $PATH_PREFIX/modules --provider-data $PATH_PREFIX/providers --key-data $PATH_PREFIX/keys" - fi - - go run ./cmd/generate-v1 --destination ../../generated $DATA_DIR_FLAGS + working-directory: ./src + run: go run ./cmd/generate-v1 --destination ../generated env: GH_TOKEN: ${{ secrets.GH_TOKEN }} From 4aa91bbdbfa7aa2dbbce451db3a37c1db687338c Mon Sep 17 00:00:00 2001 From: Ronny Orot Date: Wed, 13 Dec 2023 15:04:15 +0200 Subject: [PATCH 10/10] We don't need Development-with-delete env, use Development instead Signed-off-by: Ronny Orot --- .github/workflows/generate-and-deploy-with-delete.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-and-deploy-with-delete.yml b/.github/workflows/generate-and-deploy-with-delete.yml index 1c5784ea6a..92199fe434 100644 --- a/.github/workflows/generate-and-deploy-with-delete.yml +++ b/.github/workflows/generate-and-deploy-with-delete.yml @@ -8,7 +8,7 @@ on: type: choice description: The environment of the Registry options: - - Development-with-delete + - Development - Production-with-delete jobs: