mirror of
https://github.com/rancher/rke.git
synced 2025-07-30 22:44:50 +00:00
Add GitHub Actions workflow for go-generate
This commit is contained in:
parent
2159597d0f
commit
a4533e74c3
62
.github/workflows/git-actions-go-generate.yml
vendored
Normal file
62
.github/workflows/git-actions-go-generate.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
name: Go Generate
|
||||
on: workflow_dispatch
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
jobs:
|
||||
go-generate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v2
|
||||
- name: Run go-generate to fetch data.json
|
||||
run: make go-generate
|
||||
- name: Check for repository changes
|
||||
run: |
|
||||
if git diff --name-only --exit-code; then
|
||||
echo "No changes found in repository after 'go generate'"
|
||||
echo "changes_exist=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Changes found in repository after 'go generate':"
|
||||
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-generate-$(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 generate'
|
||||
git push origin "$BRANCH"
|
||||
- name: Create Pull Request
|
||||
if: ${{ env.changes_exist == 'true' }}
|
||||
id: cpr
|
||||
uses: actions/github-script@v5.0.0
|
||||
env:
|
||||
SOURCE_BRANCH: ${{ steps.branch.outputs.branch }}
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const { data: pr } = await github.rest.pulls.create({
|
||||
title: "[${{ github.ref_name }}] go generate",
|
||||
body: 'Auto-generated by GitHub Actions',
|
||||
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"],
|
||||
});
|
||||
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 }}"
|
@ -24,7 +24,7 @@ RUN wget -O - ${!DOCKER_URL} > /usr/bin/docker && chmod +x /usr/bin/docker
|
||||
|
||||
ENV DAPPER_SOURCE /go/src/github.com/rancher/rke/
|
||||
ENV DAPPER_RUN_ARGS --privileged -v /var/lib/docker
|
||||
ENV DAPPER_OUTPUT ./bin ./dist ./build/bin
|
||||
ENV DAPPER_OUTPUT ./bin ./dist ./build/bin ./data
|
||||
ENV DAPPER_DOCKER_SOCKET true
|
||||
ENV DAPPER_ENV TAG REPO GOOS CROSS DRONE_TAG
|
||||
ENV HOME ${DAPPER_SOURCE}
|
||||
|
2
scripts/go-generate
Executable file
2
scripts/go-generate
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
go generate
|
Loading…
Reference in New Issue
Block a user