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

Initial commit for automated release #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
68 changes: 68 additions & 0 deletions .github/workflows/crossplane-release-refresh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Trigger PR for cross plane release
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Crossplane


#on:
# release:
# types: [published] # Trigger when a new release is published
on:
workflow_dispatch:

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

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set Up Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'

- name: Clone provider-palette repository
run: git clone https://github.com/crossplane-contrib/provider-palette.git

- name: Get Latest Release
id: get_release
uses: actions/github-script@v6
with:
script: |
const owner = 'spectrocloud';
const repo = 'terraform-provider-spectrocloud';
const latestRelease = await github.rest.repos.getLatestRelease({
owner,
repo,
});
core.setOutput('latest_version', latestRelease.data.tag_name);
console.log(`Latest release tag: ${latestRelease.data.tag_name}`);

- name: Update Makefile
run: |
cd provider-palette
sed -i 's/^export TERRAFORM_PROVIDER_VERSION := .*/export TERRAFORM_PROVIDER_VERSION := ${{ steps.get_release.outputs.latest_version }}/' Makefile

- name: Install goimports
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you moved this step up you could club the one above it and the two below it together into a single step and only need to cd provider-palette once.

run: go install golang.org/x/tools/cmd/goimports@latest

- name: Run make commands
run: |
cd provider-palette
make submodules vendor vendor.check
make generate

- name: Commit and Push Changes
run: |
cd provider-palette
git checkout -b update-terraform-provider-${{ github.event.release.tag_name }}
git add Makefile
git add .
Copy link
Collaborator

Choose a reason for hiding this comment

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

Only git add . should be sufficient. No need to git add Makefile first.

git commit -m "Update Terraform Provider to version ${{ github.event.release.tag_name }}"
git push origin update-terraform-provider-${{ github.event.release.tag_name }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is going to fail unless you configure auth using a PAT that has push access for provider-palette.


- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update-terraform-provider-${{ github.event.release.tag_name }}
title: "Update Terraform Provider to version ${{ github.event.release.tag_name }}"
body: "This PR updates the Terraform Provider version to ${{ github.event.release.tag_name }}."
Loading