forked from maykinmedia/objects-api
-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (64 loc) · 2.52 KB
/
oaf-check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: open-api-workflow oaf-check
on:
workflow_call:
workflow_dispatch:
jobs:
oaf-up-to-date:
name: Check for new OAF version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
cache: 'pip'
cache-dependency-path: 'requirements/*.txt'
- name: Install dependencies
run: pip install $(grep "pip-tools==" requirements/dev.txt)
- name: Run compile dependencies
run: ./bin/compile_dependencies.sh --upgrade-package open-api-framework
- name: Check git diff
run: git diff --exit-code -- requirements/*.txt
create-oaf-update-pr:
name: Create a pull requests to update OAF
runs-on: ubuntu-latest
needs: [oaf-up-to-date]
if: failure()
steps:
- uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- uses: actions/setup-python@v5
with:
python-version: 3.11
cache: 'pip'
cache-dependency-path: 'requirements/*.txt'
- name: Install dependencies
run: pip install $(grep "pip-tools==" requirements/dev.txt)
- name: Run compile dependencies
run: ./bin/compile_dependencies.sh --upgrade-package open-api-framework
- name: Get OAF Version
run: echo "OAF_VERSION=$(grep -Po '(?<=open-api-framework==)[^\n]*' requirements/dev.txt)" >> $GITHUB_ENV
# Git
- name: Create and Checkout Branch
run: git checkout -q -B update/open-api-framework-${{env.OAF_VERSION}}
- name: Commit Changes
run: "git commit -i requirements/*.txt -m ':arrow_up: Update Open-API-Framework to ${{env.OAF_VERSION}}'"
- name: Push Changes
run: git push -f --set-upstream origin update/open-api-framework-${{env.OAF_VERSION}}
# GitHub
- name: Check for Existing PR
id: existing-pr
continue-on-error: true
run: gh pr view update/open-api-framework-${{env.OAF_VERSION}} >> /dev/null
env:
GH_TOKEN: ${{ github.token }}
- name: Create New PR
run: |
gh pr create --title "Update Open API Framework to ${{env.OAF_VERSION}}"\
--body "[Auto generated with github action.]($ACTION_URL)"
env:
GH_TOKEN: ${{ github.token }}
ACTION_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"