Skip to content

Update binary files from artifact #38

Update binary files from artifact

Update binary files from artifact #38

Workflow file for this run

name: Generate and Update Build File
on:
pull_request:
types:
- closed
branches:
- main
- '!update-binary-files'
permissions:
contents: write
pull-requests: write
jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Run go mod tidy
run: go mod tidy
- name: Run go test
run: go test ./...
- name: Run go build
run: go build -o swagen
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: swagen
path: swagen
create-pr:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: swagen
path: .
- name: Configure Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create new branch from merged branch
run: |
if git show-ref --verify --quiet refs/heads/update-binary-files; then
git checkout update-binary-files
else
git checkout -b update-binary-files
fi
git add swagen
git diff --exit-code || git commit -m "Update binary files from artifact" && git push origin update-binary-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update binary files from artifact
title: Update binary files from artifact
delete-branch: true
branch: update-binary-files
base: main
- name: Auto-merge PR
uses: pascalgn/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
merge-method: squash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}