Skip to content

Commit

Permalink
ci: Added auto-update.yml.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 6, 2024
1 parent c999ee9 commit dd42c88
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/auto-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Opens a new PR if there are OpenAPI updates
#on:
# schedule:
# - cron: '0 6 * * *'
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write
actions: write

jobs:
open-router:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Git user
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions[bot]"
- name: Generate branch name
id: branch
run: echo "branch_name=bot/update-openapi_$(date +'%Y%m%d%H%M')" >> $GITHUB_OUTPUT

- name: Create branch
run: |
git checkout -b ${{ steps.branch.outputs.branch_name }} origin/main
git rebase main
- name: Generate code
run: |
src/libs/OpenAI/generate.sh
- name: Check for changes
id: changes
run: |
CHANGED=$(git diff --name-only)
if [ -z "$CHANGED" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.changes.outputs.has_changes == 'true'
run: |
git add .
git commit -m "feat: Updated OpenAPI spec"
git push --force-with-lease -u origin ${{ steps.branch.outputs.branch_name }}
- name: Wait for 15 seconds
if: steps.changes.outputs.has_changes == 'true'
run: sleep 15

- name: Create pull request
if: steps.changes.outputs.has_changes == 'true'
run: gh pr create -B main -H ${{ steps.branch.outputs.branch_name }} --title 'feat:Updated OpenAPI spec' --body 'Created by Github Actions'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions OpenAI.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
LICENSE = LICENSE
README.md = README.md
.github\dependabot.yml = .github\dependabot.yml
.github\workflows\auto-merge.yml = .github\workflows\auto-merge.yml
.github\workflows\auto-update.yml = .github\workflows\auto-update.yml
.github\workflows\pull-request.yml = .github\workflows\pull-request.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{61E7E11E-4558-434C-ACE8-06316A3097B3}"
Expand Down

0 comments on commit dd42c88

Please sign in to comment.