Skip to content

Commit

Permalink
add update terraform provider version action
Browse files Browse the repository at this point in the history
  • Loading branch information
yfodil committed Dec 5, 2023
1 parent cea3ddb commit 3ee96b6
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/update-terraform-provider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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@v2
with:
ref: ${{ github.head_ref }}

- name: Install jq
run: sudo apt-get install jq

- name: Check for New Terraform Provider Release
id: check_release
run: |
API_URL="https://api.github.com/repos/scaleway/terraform-provider-scaleway/releases/latest"
latest_release=$(curl -s $API_URL)
latest_version=$(echo $latest_release | jq -r '.tag_name' | sed 's/^v//')
echo "Latest version: $latest_version"
echo "new_version=$latest_version" >> $GITHUB_ENV
- name: Read Current Terraform Provider Version from Makefile
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: Commit and Push Changes
if: env.new_version != env.current_version
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update Terraform provider to ${{ env.new_version }}"
branch: ${{ github.head_ref }}

0 comments on commit 3ee96b6

Please sign in to comment.