Terraform Provider Version Bump #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Terraform Provider Version Bump | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 15 * * *" # Run at 15:00 UTC every day | |
env: | |
GO_VERSION: "1.23" | |
PROVIDER_SOURCE: "launchdarkly/launchdarkly" | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
jobs: | |
bump-version-makefile: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 | |
with: | |
submodules: true | |
- name: Setup Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Find the Go Build Cache | |
id: go | |
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT | |
- name: Cache the Go Build Cache | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | |
with: | |
path: ${{ steps.go.outputs.cache }} | |
key: ${{ runner.os }}-build-lint-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-build-lint- | |
- name: Cache Go Dependencies | |
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 | |
with: | |
path: .work/pkg | |
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }} | |
restore-keys: ${{ runner.os }}-pkg- | |
- name: Vendor Dependencies | |
run: make vendor vendor.check | |
- name: Bump terraform provider version in Makefile | |
id: bump-mk | |
run: | | |
sed -i -E "s/^(export[[:space:]]+TERRAFORM_PROVIDER_VERSION[[:space:]]*(:|\?)=[[:space:]]*).+/\1$(curl -sL 'https://registry.terraform.io/v1/providers/${{ env.PROVIDER_SOURCE }}' | jq -r .version)/" Makefile | |
echo "bumped=$(git diff --name-only Makefile)" >> $GITHUB_OUTPUT | |
echo "version=$(curl -sL 'https://registry.terraform.io/v1/providers/${{ env.PROVIDER_SOURCE }}' | jq -r .version)" >> $GITHUB_OUTPUT | |
- name: Install goimports & run make generate | |
if: steps.bump-mk.outputs.bumped != '' | |
run: | | |
go install golang.org/x/tools/cmd/goimports | |
make generate | |
- name: New pull request | |
if: steps.bump-mk.outputs.bumped != '' | |
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 | |
with: | |
title: "feat: Bump terraform provider to version ${{ steps.bump-mk.outputs.version }}" | |
commit-message: Bump terraform provider to version ${{ steps.bump-mk.outputs.version }} | |
committer: GitHub <[email protected]> | |
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> | |
base: main | |
token: ${{ secrets.GITHUB_TOKEN }} | |
signoff: false | |
labels: | | |
automated |