Skip to content

Commit e1b0e41

Browse files
bugfix: use github action cache to speed up pipeline (#69)
Signed-off-by: Tsung-Ju Lii <[email protected]>
1 parent 895b48b commit e1b0e41

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

.github/workflows/create_album_post.yaml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,55 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v4
2323

24+
- name: Cache Haskell dependencies
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.cabal/store
29+
.github/scripts/pull_album_info/dist-newstyle
30+
key: haskell-cache-${{ runner.os }}-${{ hashFiles('.github/scripts/pull_album_info/cabal.project.freeze') }}
31+
restore-keys: |
32+
haskell-cache-${{ runner.os }}-
33+
2434
- name: Setup Haskell
2535
uses: haskell-actions/[email protected]
2636
with:
2737
ghc-version: 9.4.8
2838

29-
- name: Pull album info
30-
id: pull_album_info
39+
- name: Build
3140
run: |
32-
BRANCH_NAME=$(echo "${{ github.event.inputs.album_title }}-${{ github.event.inputs.artist_name }}" | tr '[:upper:]' '[:lower:]' | tr -cd 'a-z0-9-')
33-
34-
# Build album template post
3541
cd .github/scripts/pull_album_info
42+
43+
# Ensure dependencies are up-to-date
44+
cabal update
45+
cabal freeze
46+
47+
# Build the app
3648
cabal build
49+
50+
- name: Set branch name
51+
id: set_name
52+
run: |
53+
BRANCH_NAME=$(echo "${{ github.event.inputs.album_title }}-${{ github.event.inputs.artist_name }}" | tr '[:upper:]' '[:lower:]' | tr -cd 'a-z0-9-')
54+
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
55+
56+
- name: Run
57+
run: |
58+
BRANCH_NAME=${{ steps.set_name.outputs.branch_name }}
3759
cabal run pull-album-info ${{ github.event.inputs.artist_name }} ${{ github.event.inputs.album_title }} $BRANCH_NAME
3860
mv $BRANCH_NAME ${{ github.workspace }}/drafts/$BRANCH_NAME
3961
4062
# Switch to bot account
4163
git config --global user.name 'github-actions[bot]'
4264
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
4365
44-
# Set branch name to output
45-
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
46-
4766
- name: Create Pull Request
4867
id: create_pr
4968
uses: peter-evans/create-pull-request@v7
5069
with:
5170
token: ${{ secrets.GITHUB_TOKEN }}
52-
branch: ${{ steps.pull_album_info.outputs.branch_name }}
71+
branch: ${{ steps.set_name.outputs.branch_name }}
5372
base: main
54-
title: post/${{ steps.pull_album_info.outputs.branch_name }}
55-
body-path: '${{ github.workspace }}/drafts/${{ steps.pull_album_info.outputs.branch_name }}'
73+
title: post/${{ steps.set_name.outputs.branch_name }}
74+
body-path: '${{ github.workspace }}/drafts/${{ steps.set_name.outputs.branch_name }}'
5675
labels: 'post'

0 commit comments

Comments
 (0)