generated from growthatco/template
-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (141 loc) · 6.5 KB
/
integration.yaml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
name: Integration
on:
pull_request:
branches:
- main
- next
jobs:
setup:
name: Setup
runs-on: ubuntu-20.04
steps:
- name: Cancel Duplicate Jobs
uses: fkirc/skip-duplicate-actions@v3.4.1
with:
github_token: ${{ (secrets.GROWTHAT_BOT_TOKEN || github.token) }}
cancel_others: true
commit-lint:
name: Commit Lint
runs-on: ubuntu-20.04
needs: setup
steps:
- name: Checkout Code
uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v14
- name: Build Nix Dependencies
run: |
nix-shell shell.ci.nix --run "echo 'Successfully built nix dependencies.'"
- name: Run `commitlint`
run: |
nix-shell shell.ci.nix --pure --run "npx commitlint --verbose --from origin/${{ github.base_ref }} --to ${{ github.head_ref }}"
mega-linter:
name: Mega-Linter
runs-on: ubuntu-20.04
needs: setup
steps:
- name: Checkout Code
uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
token: ${{ (secrets.GROWTHAT_BOT_TOKEN || github.token) }}
- name: Run Mega-Linter
id: mega-linter-action
env:
GITHUB_TOKEN: ${{ github.token }}
PAT: ${{ (secrets.GROWTHAT_BOT_TOKEN || github.token) }}
run: |
npx mega-linter-runner \
--env APPLY_FIXES_EVENT=pull_request \
--env APPLY_FIXES_MODE=commit \
--env VALIDATE_ALL_CODEBASE=true \
--env GITHUB_TOKEN=${{ env.GITHUB_TOKEN }} \
--env PAT=${{ env.PAT }} \
--fix
# Upload Mega-Linter artifacts
- name: Archive production artifacts
if: ${{ !env.ACT && (success() || failure()) }}
uses: actions/upload-artifact@v2
with:
name: Mega-Linter reports
path: |
report
mega-linter.log
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
- name: Create Pull Request with applied fixes
id: create-pull-request-action
if: ${{ !env.ACT && steps.mega-linter-action.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') }}
uses: peter-evans/create-pull-request@v3
with:
author: ${{ secrets.GROWTHAT_BOT_NAME }} ${{ secrets.GROWTHAT_BOT_EMAIL }}
base: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
committer: ${{ secrets.GROWTHAT_BOT_NAME }} ${{ secrets.GROWTHAT_BOT_EMAIL }}
commit-message: "style(mega-linter): apply linter fixes"
labels: bot
token: ${{ (secrets.GROWTHAT_BOT_TOKEN || github.token) }}
title: "[Mega-Linter] Apply linters automatic fixes"
- name: Create PR output
if: ${{ !env.ACT && steps.mega-linter-action.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') }}
run: |
echo "Pull Request Number - ${{ steps.create-pull-request-action.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.create-pull-request-action.outputs.pull-request-url }}"
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
- name: Prepare commit
if: ${{ !env.ACT && steps.mega-linter-action.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') }}
run: sudo chown -Rc $UID .git/
- name: Commit and push applied linter fixes
if: ${{ !env.ACT && steps.mega-linter-action.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') }}
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
commit_message: "style(mega-linter): apply linter fixes"
commit_user_name: ${{ secrets.GROWTHAT_BOT_NAME }}
commit_user_email: ${{ secrets.GROWTHAT_BOT_EMAIL }}
dry-run-release:
name: Dry Run Release
runs-on: ubuntu-20.04
needs: setup
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
persist-credentials: false
- name: Install Nix
uses: cachix/install-nix-action@v14
- name: Build Nix Dependencies
run: |
nix-shell shell.cd.nix --run "echo 'Successfully built nix dependencies.'"
- name: Install Node.js dependencies
run: |
nix-shell shell.cd.nix --run "npm ci"
- name: Release
env:
GH_TOKEN: ${{ (secrets.GROWTHAT_BOT_TOKEN || github.token) }}
GITHUB_TOKEN: ${{ (secrets.GROWTHAT_BOT_TOKEN || github.token) }}
GIT_AUTHOR_NAME: ${{ secrets.GROWTHAT_BOT_NAME }}
GIT_AUTHOR_EMAIL: ${{ secrets.GROWTHAT_BOT_EMAIL }}
GIT_COMMITTER_NAME: ${{ secrets.GROWTHAT_BOT_NAME }}
GIT_COMMITTER_EMAIL: ${{ secrets.GROWTHAT_BOT_EMAIL }}
run: |
nix-shell shell.cd.nix --run "npm run release-dry-run"
test:
name: Test
runs-on: ubuntu-20.04
needs:
- commit-lint
- mega-linter
- dry-run-release
steps:
- name: Checkout Code
uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- name: Install Nix
uses: cachix/install-nix-action@v14
- name: Build Nix Dependencies
run: |
nix-shell shell.ci.nix --run "echo 'Successfully built nix dependencies.'"