-
Notifications
You must be signed in to change notification settings - Fork 4
93 lines (81 loc) · 2.82 KB
/
openapi.yaml
File metadata and controls
93 lines (81 loc) · 2.82 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# A lot of this was inspired by https://brunoscheufler.com/blog/2022-04-24-required-github-actions-jobs-in-a-monorepo
name: OpenAPI spec
on:
pull_request:
paths:
- 'api/src/Entity'
- '.github/workflows/openapi.yaml'
jobs:
change-detection:
runs-on: ubuntu-latest
outputs:
openapi: ${{ steps.changes.outputs.openapi }}
steps:
- uses: dorny/paths-filter@v2
id: changes
with:
list-files: shell
filters: |
openapi:
- 'api/src/Entity/**'
build:
needs: change-detection
if: needs.change-detection.outputs.openapi == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Start the containers]
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up -d --build
- name: Install composer packages
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml exec -T api composer install
- name: Run Database migrations
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml exec -T api bin/console --no-interaction doctrine:migration:migrate
- name: Generate openapi.yaml
run: docker-compose exec -T api bash -c "bin/console api:openapi:export --yaml" > ../docs/generated/openapi.yaml
- name: Archive openapi artifacts
uses: actions/upload-artifact@v3
with:
name: openapi_spec_artifact
path: |
docs/generated
- name: Stop containers
if: always()
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml down
after-build:
needs: build # run after tests
runs-on: ubuntu-latest
if: success() # only run when all test have passed
# store success output flag for ci job
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- id: setoutput
run: echo "::set-output name=success::true"
dummy-step:
runs-on: ubuntu-latest
needs: change-detection
# runs if API was not changed
if: needs.change-detection.outputs.openapi == 'false'
outputs:
success: ${{ steps.setoutput.outputs.success }}
steps:
- id: setoutput
run: echo "::set-output name=success::true"
# step that will be used for required status check
# make sure it has a unique name! this will always run, but
# after the tests & after-tests steps or the dummy step in case
# the API was not modified
ci_openapi:
runs-on: ubuntu-20.04
if: always()
needs: [build, after-build, dummy-step]
steps:
- run: |
passed="${{ needs.after-build.outputs.success || needs.dummy-step.outputs.success }}"
if [[ $passed == "true" ]]; then
echo "Build passed"
exit 0
else
echo "Build failed"
exit 1
fi