xref: /expo/.github/workflows/pr-labeler.yml (revision 5df91f7e)
1name: PR labeler
2
3on:
4  push:
5    branches: [main]
6    paths:
7      - .github/workflows/pr-labeler.yml
8      - apps/bare-expo/**
9      - apps/test-suite/**
10      - packages/**
11      - yarn.lock
12  pull_request:
13    types: [opened, synchronize]
14    paths:
15      - .github/workflows/pr-labeler.yml
16      - apps/bare-expo/**
17      - apps/test-suite/**
18      - packages/**
19      - yarn.lock
20
21concurrency:
22  group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
23  cancel-in-progress: true
24
25jobs:
26  test-suite-fingerprint:
27    runs-on: ubuntu-22.04
28    # REQUIRED: limit concurrency when pushing main(default) branch to prevent conflict for this action to update its fingerprint database
29    concurrency: fingerprint-${{ github.event_name != 'pull_request' && 'main' || github.run_id }}
30    permissions:
31      # REQUIRED: Allow comments of PRs
32      pull-requests: write
33      # REQUIRED: Allow updating fingerprint in acton caches
34      actions: write
35    steps:
36      - name: �� Checkout
37        uses: actions/checkout@v3
38        with:
39          submodules: true
40      - name: ⬢ Setup Node
41        uses: actions/setup-node@v3
42        with:
43          node-version: 18
44      - name: ♻️ Restore caches
45        uses: ./.github/actions/expo-caches
46        id: expo-caches
47        with:
48          yarn-workspace: 'true'
49      - name: �� Install node modules in root dir
50        if: steps.expo-caches.outputs.yarn-workspace-hit != 'true'
51        run: yarn install --frozen-lockfile
52      - name: �� Check fingerprint
53        id: fingerprint
54        uses: expo/expo-github-action/fingerprint@main
55        with:
56          working-directory: apps/bare-expo
57
58      - name: ��️ Labeling PR
59        uses: actions/github-script@v6
60        if: ${{ github.event_name == 'pull_request' && steps.fingerprint.outputs.fingerprint-diff == '[]' }}
61        with:
62          script: |
63            try {
64              await github.rest.issues.removeLabel({
65                issue_number: context.issue.number,
66                owner: context.repo.owner,
67                repo: context.repo.repo,
68                name: ['bot: fingerprint changed']
69              })
70            } catch (e) {
71              if (e.status != 404) {
72                throw e;
73              }
74            }
75            github.rest.issues.addLabels({
76              issue_number: context.issue.number,
77              owner: context.repo.owner,
78              repo: context.repo.repo,
79              labels: ['bot: fingerprint compatible']
80            })
81      - name: ��️ Labeling PR
82        uses: actions/github-script@v6
83        if: ${{ github.event_name == 'pull_request' && steps.fingerprint.outputs.fingerprint-diff != '[]' }}
84        with:
85          script: |
86            try {
87              await github.rest.issues.removeLabel({
88                issue_number: context.issue.number,
89                owner: context.repo.owner,
90                repo: context.repo.repo,
91                name: ['bot: fingerprint compatible']
92              })
93            } catch (e) {
94              if (e.status != 404) {
95                throw e;
96              }
97            }
98            github.rest.issues.addLabels({
99              issue_number: context.issue.number,
100              owner: context.repo.owner,
101              repo: context.repo.repo,
102              labels: ['bot: fingerprint changed']
103            })
104