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 diff --git a/.github/workflows/bump-versions.yml b/.github/workflows/bump-versions.yml index 03ec7137d5..eb8d881278 100644 --- a/.github/workflows/bump-versions.yml +++ b/.github/workflows/bump-versions.yml @@ -1,15 +1,26 @@ 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 + workflow_call: + inputs: + environment: + type: string + description: The environment of the Registry jobs: bump-versions: runs-on: ubuntu-latest - environment: Development + environment: + name: ${{ inputs.environment }} permissions: contents: write actions: write @@ -28,12 +39,24 @@ jobs: working-directory: ./src run: go run ./cmd/bump-versions + - name: Get branch + id: 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 + branch: ${{ env.BRANCH }} + create_branch: true - - name: Invoke publish workflow - uses: benc-uk/workflow-dispatch@v1 - with: - workflow: generate-and-deploy.yml + - name: Print Branch name + run: | + echo "Providers and modules changes were pushed to branch: ${{ env.BRANCH }}" \ No newline at end of file diff --git a/.github/workflows/generate-and-deploy-with-delete.yml b/.github/workflows/generate-and-deploy-with-delete.yml index 22be50be42..92199fe434 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 + - Production-with-delete jobs: generate-and-sync: runs-on: ubuntu-latest - - environment: Production-with-delete + environment: + name: ${{ inputs.environment }} steps: - name: Checkout Repository @@ -26,7 +33,7 @@ jobs: working-directory: ./src run: go run ./cmd/generate-v1 --destination ../generated 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 f47ee558d9..b5f4c330d7 100644 --- a/.github/workflows/generate-and-deploy.yml +++ b/.github/workflows/generate-and-deploy.yml @@ -2,13 +2,25 @@ name: Generate and Sync Files on: - workflow_dispatch + workflow_dispatch: + inputs: + environment: + type: choice + description: The environment of the Registry + options: + - Development + - Production + workflow_call: + inputs: + environment: + type: string + description: The environment of the Registry jobs: generate-and-sync: runs-on: ubuntu-latest - - environment: Production + environment: + name: ${{ inputs.environment }} steps: - name: Checkout Repository @@ -26,7 +38,7 @@ jobs: working-directory: ./src run: go run ./cmd/generate-v1 --destination ../generated 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 }}