72 lines (67 loc) · 2.53 KB
/
wingsdk-mutation.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
name: WingSDK Mutation
on:
pull_request_target:
types:
- opened
- synchronize
paths:
- libs/wingsdk/**
permissions:
contents: write
defaults:
run:
working-directory: libs/wingsdk
env:
CI: "true"
jobs:
mutate:
runs-on: ubuntu-latest
steps:
- id: token-check
name: Check if mutation token is set
working-directory: ${{ github.workspace }}
run: echo "HAS_TOKEN=${{ secrets.MUTATION_TOKEN && 'true' || 'false' }}" >> $GITHUB_OUTPUT
- name: Token notice
if: steps.token-check.outputs.HAS_TOKEN == 'false'
working-directory: ${{ github.workspace }}
run: |
echo "Add a MUTATION_TOKEN repository secret with a personal access token to enable self mutation.
It requires read/write repo permissions." >> $GITHUB_STEP_SUMMARY
- name: Checkout
if: steps.token-check.outputs.HAS_TOKEN == 'true'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.MUTATION_TOKEN }}
# Reads versions from root package.json "volta" section
- name: Setup Node/NPM with pinned Volta version
uses: volta-cli/action@v4.0.0
- name: Install dependencies
if: steps.token-check.outputs.HAS_TOKEN == 'true'
run: npm ci
working-directory: "."
- name: Build transitive dependency (wing-api-checker)
if: steps.token-check.outputs.HAS_TOKEN == 'true'
run: npm run build
working-directory: apps/wing-api-checker
- name: Build transitive dependency (jsii-docgen)
if: steps.token-check.outputs.HAS_TOKEN == 'true'
run: npm run build
working-directory: apps/jsii-docgen
- name: build
if: steps.token-check.outputs.HAS_TOKEN == 'true'
run: npx projen build
- id: self_mutation
if: steps.token-check.outputs.HAS_TOKEN == 'true'
name: Find mutations
run: |-
git add --all
git diff --staged --patch --exit-code > /dev/null || echo "::set-output name=self_mutation_happened::true"
- name: Push changes
if: steps.token-check.outputs.HAS_TOKEN == 'true' && steps.self_mutation.outputs.self_mutation_happened
run: |-
git config user.name "monada-bot[bot]"
git config user.email "monabot@monada.co"
git commit -s -m "chore: self mutation"
git push origin HEAD:${{ github.event.pull_request.head.ref }}