Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create registry dev environment #95

Merged
merged 11 commits into from
Dec 13, 2023
20 changes: 20 additions & 0 deletions .github/workflows/bump-and-publish-versions-prod.yml
Original file line number Diff line number Diff line change
@@ -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"
37 changes: 30 additions & 7 deletions .github/workflows/bump-versions.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
cam72cam marked this conversation as resolved.
Show resolved Hide resolved
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
cam72cam marked this conversation as resolved.
Show resolved Hide resolved

- 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 }}"
15 changes: 11 additions & 4 deletions .github/workflows/generate-and-deploy-with-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
This conversation was marked as resolved.
Show resolved Hide resolved
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/generate-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
This conversation was marked as resolved.
Show resolved Hide resolved
Expand Down