aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/update_mergify.yml
blob: d2067a42de2776d3a130dadb249c629083ecf24e (plain)
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
name: Update .mergify.yml
on:
  schedule:
    # Runs once an hour
    - cron: "0 * * * *"

jobs:
  update-mergify:
    name: Update .mergify.yml
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Checkout Chisel Repo Tools
        uses: actions/checkout@v2
        with:
          repository:  ucb-bar/chisel-repo-tools
          path: tools
      - name: Setup Scala
        uses: olafurpg/setup-scala@v10
      - name: Install Ammonite
        run: sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/com-lihaoyi/Ammonite/releases/download/2.3.8/2.13-2.3.8) > /usr/local/bin/amm && chmod +x /usr/local/bin/amm'
      - name: Cache Scala
        uses: coursier/cache-action@v6
      - name: Generate .mergify.yml
        id: gen
        run: |
          ./tools/scripts/mergify.sc .github/configs/mergify_config.yml > .mergify.yml
          diff=$(git diff -- .mergify.yml)
          echo "::set-output name=diff::$diff"
      - name: Commit and Push
        if: ${{ steps.gen.outputs.diff }}
        run: |
          BRANCH="actions/workflows/update-mergify"
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          git checkout -B $BRANCH
          git add .mergify.yml
          git commit -m "Update .mergify.yml"
          git push --follow-tags --force --set-upstream origin $BRANCH
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Open/Update Pull Request
        if: ${{ steps.gen.outputs.diff }}
        uses: vsoch/pull-request-action@1.0.15
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PULL_REQUEST_FROM_BRANCH: actions/workflows/update-mergify
          PULL_REQUEST_BRANCH: master
          PULL_REQUEST_TITLE: "Update .mergify.yml"
          PULL_REQUEST_BODY: "This is an automated pull request by \"Update .mergify.yml\" workflow"
          PASS_IF_EXISTS: true