-
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (107 loc) · 5.15 KB
/
integrate.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# https://docs.github.com/en/actions
name: 'Integrate'
on: # yamllint disable-line rule:truthy
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
workflow_call: null
push:
branches:
- 'main'
concurrency:
group: ${{ github.sha }}
cancel-in-progress: true
permissions:
pull-requests: write
issues: write
repository-projects: write
contents: write
jobs:
php:
runs-on: ubuntu-latest
if: |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}
- uses: ./.github/actions/setup-environment
# Check dependencies
- run: symfony composer validate
- run: symfony check:security
# Prepare tests
- run: symfony console cache:clear
# Init database
- run: APP_ENV=test symfony console doctrine:schema:validate --skip-sync
- run: APP_ENV=test symfony console doctrine:migrations:migrate --no-interaction
- run: APP_ENV=test symfony console doctrine:fixtures:load --no-interaction
# Lint Twig, Yaml and XLIFF files
- run: symfony console lint:twig templates
- run: symfony console lint:yaml config --parse-tags
- run: symfony console lint:xliff translations
- run: symfony console lint:container
# Run static code analysis tools
- run: symfony php vendor/bin/phpinsights -n --ansi --format=github-action
- run: APP_ENV=test symfony php vendor/bin/phpunit # See https://github.com/symfony/symfony-docs/pull/15228
javascript:
runs-on: ubuntu-latest
if: |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}
- uses: ./.github/actions/setup-environment
# Lint files
- run: npm run lint:js --no-fix
- run: npm run lint:css --no-fix
# Tests
#- run: npm run test:unit --if-present
# Build assets for dev and prod
- run: npm run dev
- run: npm run build
cypress:
runs-on: ubuntu-latest
name: cypress
if: |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || '' }}
- uses: ./.github/actions/setup-environment
# Start Symfony Server
- run: symfony server:ca:install
- run: APP_ENV=test symfony console doctrine:migrations:migrate --no-interaction
- run: APP_ENV=test symfony console doctrine:fixtures:load --no-interaction
- run: APP_ENV=test symfony serve --port 8000 --daemon
- run: echo "CYPRESS_BASE_URL=https://localhost:8000" >> $GITHUB_ENV
- name: Run Cypress
if: ${{ env.IS_DEPENDABOT == 'false' && ! github.event.pull_request.draft }}
uses: cypress-io/github-action@v2
with:
build: npm run build
auto_approve_and_merge:
runs-on: ubuntu-latest
needs: [php, javascript, cypress]
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Fetch Dependabot metadata
id: dependabot-metadata
uses: dependabot/[email protected]
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Approve and merge the PR
if: |
(steps.dependabot-metadata.outputs.dependency-type == 'direct:production' && steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch')
|| (steps.dependabot-metadata.outputs.dependency-type == 'direct:development' && (steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch'))
run: |
gh pr review --approve "$PR_URL"
gh pr merge --merge --auto --delete-branch "$PR_URL"
env:
PR_URL: '${{ github.event.pull_request.html_url }}'
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'