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

feat: automate Crossplane generation process #26

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ on:
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
merge_group:
schedule:
- cron: '26 4 * * 2'

Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/update-terraform-provider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Update Terraform Provider

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}

jobs:
update-terraform-provider:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Check for New Terraform Provider Release
id: check_release
run: ./scripts/check_version.sh

- name: Read Current Terraform Provider Version from Makefile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to have the full workflow inside a script so that it can be launched locally even if github action is down

id: current_version
run: |
current_version=$(awk -F ' := ' '/TERRAFORM_PROVIDER_VERSION/{print $2}' Makefile)
echo "Current version: $current_version"
echo "current_version=$current_version" >> $GITHUB_ENV

- name: Update Makefile
if: env.new_version != env.current_version
run: |
new_version="${{ env.new_version }}"
sed -i "s/TERRAFORM_PROVIDER_VERSION := .*/TERRAFORM_PROVIDER_VERSION := $new_version/" Makefile
sed -i "s/TERRAFORM_NATIVE_PROVIDER_BINARY := terraform-provider-scaleway_v.*/TERRAFORM_NATIVE_PROVIDER_B

- name: Read Current Provider Metadata
run: |
echo "CURRENT_METADATA=$(cat config/provider-metadata.yaml)" >> $GITHUB_ENV

- name: Update Provider Metadata
run: make generate

- name: Read New Provider Metadata
run: |
echo "NEW_METADATA=$(cat config/provider-metadata.yaml)" >> $GITHUB_ENV

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.22'

- name: Compare Provider Metadata
id: compare_provider_metadata
run: echo "::set-output name=resource_configs::$(go run ./config/tools/comparator/main.go)"

- name: Generate Configurations for New Resources
run: echo ${{ steps.compare_provider_metadata.outputs.resource_configs }} | go run ./config/tools/generator/main.go

- name: Commit and Push Changes
if: env.new_version != env.current_version || steps.compare_provider_metadata.outputs.new_resources
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update Terraform provider to ${{ env.new_version }} and generate new resources"
branch: ${{ github.head_ref }}
10 changes: 0 additions & 10 deletions apis/sdb/v1alpha1/zz_generated.conversion_hubs.go

This file was deleted.

222 changes: 0 additions & 222 deletions apis/sdb/v1alpha1/zz_generated.deepcopy.go

This file was deleted.

68 changes: 0 additions & 68 deletions apis/sdb/v1alpha1/zz_generated.managed.go

This file was deleted.

17 changes: 0 additions & 17 deletions apis/sdb/v1alpha1/zz_generated.managedlist.go

This file was deleted.

Loading
Loading