Go get #3
This file contains 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: Go get | |
on: | |
workflow_dispatch: | |
inputs: | |
goget_module: | |
type: string | |
description: "What Go module to get" | |
goget_version: | |
type: string | |
description: "What Go module version to get" | |
source_url: | |
type: string | |
description: "URL of the source for this workflow run" | |
source_author: | |
type: string | |
description: "Username of the source for this workflow run" | |
env: | |
GOGET_MODULE: ${{ github.event.inputs.goget_module }} | |
GOGET_VERSION: ${{ github.event.inputs.goget_version }} | |
INPUT_SOURCE_URL: ${{ github.event.inputs.source_url }} | |
INPUT_SOURCE_AUTHOR: ${{ github.event.inputs.source_author }} | |
permissions: | |
contents: write | |
pull-requests: write | |
id-token: write | |
jobs: | |
go-get: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
- name: Run go get to get Go module | |
run: | | |
go list -m -mod=readonly all | grep controller | |
go version | |
make go-get | |
git status | |
- name: Run go generate | |
run: | | |
go install sigs.k8s.io/controller-tools/cmd/[email protected] | |
go generate ./... | |
git status | |
- name: Check for repository changes | |
run: | | |
if git diff --name-only --exit-code; then | |
echo "No changes found in repository after 'go get'" | |
echo "changes_exist=false" >> $GITHUB_ENV | |
else | |
echo "Changes found in repository after 'go get':" | |
git diff --name-only | |
echo "changes_exist=true" >> $GITHUB_ENV | |
fi | |
# - name: Create branch, commit and push | |
# if: ${{ env.changes_exist == 'true' }} | |
# id: branch | |
# run: | | |
# BRANCH="githubaction-go-get-$(date +%Y-%m-%d-%H-%M-%S)" | |
# echo "::set-output name=branch::$BRANCH" | |
# git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
# git config --global user.name "github-actions[bot]" | |
# git checkout -b "$BRANCH" | |
# git commit -a -m "go get ${GOGET_MODULE} ${GOGET_VERSION}" | |
# git push origin "$BRANCH" | |
# - name: Read App Secrets | |
# uses: rancher-eio/read-vault-secrets@main | |
# with: | |
# secrets: | | |
# secret/data/github/repo/${{ github.repository }}/github/app-credentials appId | APP_ID ; | |
# secret/data/github/repo/${{ github.repository }}/github/app-credentials privateKey | PRIVATE_KEY | |
# - name: Create App Token | |
# uses: actions/create-github-app-token@v1 | |
# id: app-token | |
# with: | |
# app-id: ${{ env.APP_ID }} | |
# private-key: ${{ env.PRIVATE_KEY }} | |
# - name: Create Pull Request | |
# if: ${{ env.changes_exist == 'true' }} | |
# id: cpr | |
# uses: actions/[email protected] | |
# env: | |
# SOURCE_BRANCH: ${{ steps.branch.outputs.branch }} | |
# with: | |
# github-token: ${{ steps.app-token.outputs.token }} | |
# script: | | |
# const { GOGET_MODULE, GOGET_VERSION} = process.env | |
# let body = 'Auto-generated by GitHub Actions\n\n' | |
# if ( `${ process.env.INPUT_SOURCE_URL }` ) { | |
# body += `\nSource URL: ${ process.env.INPUT_SOURCE_URL }` | |
# } | |
# if ( `${ process.env.INPUT_SOURCE_AUTHOR }` ) { | |
# body += `\nSource AUTHOR: @${ process.env.INPUT_SOURCE_AUTHOR}` | |
# } | |
# const { data: pr } = await github.rest.pulls.create({ | |
# title: `[${{ github.ref_name }}] go get ${GOGET_MODULE} ${GOGET_VERSION}`, | |
# body: body, | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# base: "${{ github.ref_name }}", | |
# head: `${ process.env.SOURCE_BRANCH }` | |
# }); | |
# await github.rest.issues.addLabels({ | |
# ...context.repo, | |
# issue_number: pr.number, | |
# labels: ["status/auto-created"], | |
# }); | |
# if ( `${ process.env.INPUT_SOURCE_AUTHOR }` ) { | |
# await github.rest.issues.addAssignees({ | |
# ...context.repo, | |
# issue_number: pr.number, | |
# assignees: [`${ process.env.INPUT_SOURCE_AUTHOR}`], | |
# }); | |
# } | |
# console.log('Created new pull request'); | |
# return pr.html_url; | |
# - name: Check outputs | |
# if: ${{ env.changes_exist == 'true' }} | |
# run: | | |
# echo "Pull Request URL - ${{ steps.cpr.outputs.result }}" |