summaryrefslogtreecommitdiffstats
path: root/.github/workflows/update.yml
blob: 053878e9e8dabd34099caf632331b5ec9850a2d1 (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
name: Update Extensions

on:
    schedule:
        - cron: '0 */4 * * *'
    workflow_dispatch:
    push:
        branches:
            - main

permissions:
    contents: write

concurrency:
    group: ${{ github.workflow }}-${{ github.ref }}
    cancel-in-progress: false

jobs:
    update:
        runs-on: ubuntu-latest
        if: github.event_name != 'push' || github.event.head_commit.author.name != 'github-actions[bot]'
        outputs:
            updated: ${{ steps.update.outputs.updated }}

        steps:
            - name: Checkout repository
              uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

            - name: Install bun
              uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
              with:
                  bun-version: latest

            - name: Install dependencies
              run: bun install --frozen-lockfile

            - name: Update extensions (quick)
              id: update
              run: bun run update --quick

            - name: Commit and push changes
              if: steps.update.outputs.updated == 'true'
              run: |
                  git config --local user.name "github-actions[bot]"
                  git config --local user.email "github-actions[bot]@users.noreply.github.com"
                  git add extensions.json
                  git diff-index --quiet HEAD || git commit -m "chore: update extensions.json"
                  git push

    sync-to-gitlab:
        runs-on: ubuntu-latest
        needs: update
        if: needs.update.outputs.updated == 'true' || github.event_name == 'workflow_dispatch'

        steps:
            - name: Checkout repository
              uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
              with:
                  ref: main
                  fetch-depth: 0

            - name: Sync to GitLab
              uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1
              with:
                  target_repo_url: ${{ secrets.GITLAB_REPO }}
                  ssh_private_key: ${{ secrets.GITLAB_SSH }}