summaryrefslogtreecommitdiff
path: root/.github/workflows/main.yml
blob: 7b3e7f4a1c83ef4695ca7ce620eb34858e3f13c0 (plain) (blame)
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
name: Main Checks

on:
  workflow_dispatch:
  push:
    branches:
      - main

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Automatically cancel in-progress actions on the same branch
concurrency:
  group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
  cancel-in-progress: true

jobs:
  congrats:
    name: congratsbot
    if: ${{ github.repository_owner == 'withastro' && github.event.head_commit.message != '[ci] format' }}
    uses: withastro/automation/.github/workflows/congratsbot.yml@main
    with:
      EMOJIS: '🎉,🎊,🧑‍🚀,🥳,🙌,🚀,👏,<:houston_golden:1068575433647456447>,<:astrocoin:894990669515489301>,<:astro_pride:1085944201587458169>'
    secrets:
      DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_CONGRATS }}

  check_for_update:
    name: Check for Updates
    runs-on: ubuntu-latest
    outputs:
      run_job: ${{ steps.check_files.outputs.run_job }}
    steps:
      - uses: actions/checkout@v3

      - name: Setup PNPM
        uses: pnpm/action-setup@v2

      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: "pnpm"

      - name: Install dependencies
        run: pnpm install

      - name: Check Modified
        run: pnpm exec changeset status --output ./status.json

      - name: Check Output
        id: check_files
        run: |
          output=`echo $(cat status.json)`
          if [[ $output = '{ "changesets": [], "releases": [] }' ]]
          then
            echo 'No changeset found'
            echo "::set-output name=run_job::true"
          else
            echo 'changes found, push to latest skipped'
            echo "::set-output name=run_job::false"
          fi

  update:
    name: Update the latest branch
    needs: check_for_update
    if: needs.check_for_update.outputs.run_job == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Push
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: latest