summaryrefslogtreecommitdiff
path: root/.github/workflows/update-colorschemes.yml
blob: 4e9db4225065198ab139dea78024dc361d35225f (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Update iTerm2 colorschemes
on:
  schedule:
    # Once a week
    - cron: "0 0 * * 0"
  workflow_dispatch:
jobs:
  update-iterm2-schemes:
    if: github.repository == 'ghostty-org/ghostty'
    runs-on: namespace-profile-ghostty-sm
    permissions:
      # Needed for create-pull-request action
      contents: write
      pull-requests: write
    env:
      ZIG_LOCAL_CACHE_DIR: /zig/local-cache
      ZIG_GLOBAL_CACHE_DIR: /zig/global-cache
    steps:
      - name: Checkout code
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          fetch-depth: 0

      - name: Setup Cache
        uses: namespacelabs/nscloud-cache-action@7baedde84bbf5063413d621f282834bc2654d0c1 # v1.2.18
        with:
          path: |
            /nix
            /zig

      - name: Setup Nix
        uses: cachix/install-nix-action@9280e7aca88deada44c930f1e2c78e21c3ae3edd # v31.7.0
        with:
          nix_path: nixpkgs=channel:nixos-unstable
      - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
        with:
          name: ghostty
          authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

      - name: Run zig fetch
        id: zig_fetch
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          # Get the latest release from iTerm2-Color-Schemes
          RELEASE_INFO=$(gh api repos/mbadolato/iTerm2-Color-Schemes/releases/latest)
          TAG_NAME=$(echo "$RELEASE_INFO" | jq -r '.tag_name')
          nix develop -c zig fetch --save="iterm2_themes" "https://github.com/mbadolato/iTerm2-Color-Schemes/releases/download/${TAG_NAME}/ghostty-themes.tgz"
          echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT

      - name: Update zig cache hash
        run: |
          # Only proceed if build.zig.zon has changed
          if ! git diff --exit-code build.zig.zon; then
            nix develop -c ./nix/build-support/check-zig-cache.sh --update
            nix develop -c ./nix/build-support/check-zig-cache.sh
          fi

      # Verify the build still works. We choose an arbitrary build type
      # as a canary instead of testing all build types.
      - name: Test Build
        run: nix build .#ghostty

      - name: Create pull request
        uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
        with:
          title: Update iTerm2 colorschemes
          base: main
          branch: iterm2_colors_action
          commit-message: "deps: Update iTerm2 color schemes"
          add-paths: |
            build.zig.zon
            build.zig.zon.nix
            build.zig.zon.txt
            build.zig.zon.json
            flatpak/zig-packages.json
          body: |
            Upstream release: https://github.com/mbadolato/iTerm2-Color-Schemes/releases/tag/${{ steps.zig_fetch.outputs.tag_name }}
          labels: dependencies