|
1 | 1 | name: Deploy LiaScript-Web-Site to Pages |
2 | 2 |
|
3 | 3 | on: |
4 | | - # Runs on pushes targeting the default branch |
5 | 4 | push: |
6 | 5 | branches: |
7 | 6 | - master |
8 | | - |
9 | | - # Allows you to run this workflow manually from the Actions tab |
10 | 7 | workflow_dispatch: |
11 | 8 |
|
12 | | -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
13 | 9 | permissions: |
14 | 10 | contents: write |
15 | 11 | pages: write |
16 | 12 | id-token: write |
17 | 13 |
|
18 | | -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
19 | | -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
20 | 14 | concurrency: |
21 | 15 | group: "pages" |
22 | 16 | cancel-in-progress: false |
23 | 17 |
|
24 | | -# Default to bash |
25 | 18 | defaults: |
26 | 19 | run: |
27 | 20 | shell: bash |
28 | 21 |
|
29 | 22 | jobs: |
30 | | - # Build job |
| 23 | + check_liascript_changes: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + should_build: ${{ steps.check.outputs.should_build }} |
| 27 | + steps: |
| 28 | + - name: Check LiaScript repository |
| 29 | + id: check |
| 30 | + run: | |
| 31 | + LAST_COMMIT=$(curl -s https://api.github.com/repos/LiaScript/LiaScript/commits/development | jq -r '.sha') |
| 32 | + echo "Last commit: $LAST_COMMIT" |
| 33 | + echo "should_build=$([ "$LAST_COMMIT" != "$(cat .liascript_last_commit 2>/dev/null)" ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT |
| 34 | + echo $LAST_COMMIT > .liascript_last_commit |
| 35 | +
|
31 | 36 | hugo: |
32 | 37 | runs-on: ubuntu-latest |
33 | 38 | env: |
|
68 | 73 | with: |
69 | 74 | name: public |
70 | 75 | path: ./public |
71 | | - |
| 76 | + |
72 | 77 | liascript: |
| 78 | + needs: check_liascript_changes |
| 79 | + if: needs.check_liascript_changes.outputs.should_build == 'true' |
73 | 80 | runs-on: ubuntu-latest |
74 | 81 | steps: |
75 | 82 | - name: Set ELM_HOME |
@@ -102,7 +109,15 @@ jobs: |
102 | 109 | name: course |
103 | 110 | path: ./LiaScript/dist |
104 | 111 |
|
| 112 | + - name: Cache LiaScript artifact |
| 113 | + uses: actions/cache@v2 |
| 114 | + with: |
| 115 | + path: ./LiaScript/dist |
| 116 | + key: ${{ runner.os }}-liascript-${{ github.sha }} |
| 117 | + |
105 | 118 | liascript-nightly: |
| 119 | + needs: check_liascript_changes |
| 120 | + if: needs.check_liascript_changes.outputs.should_build == 'true' |
106 | 121 | runs-on: ubuntu-latest |
107 | 122 | steps: |
108 | 123 | - name: Set ELM_HOME |
@@ -136,14 +151,20 @@ jobs: |
136 | 151 | name: nightly |
137 | 152 | path: ./LiaScript/dist |
138 | 153 |
|
139 | | - # Deployment job |
| 154 | + - name: Cache LiaScript-nightly artifact |
| 155 | + uses: actions/cache@v2 |
| 156 | + with: |
| 157 | + path: ./LiaScript/dist |
| 158 | + key: ${{ runner.os }}-liascript-nightly-${{ github.sha }} |
| 159 | + |
140 | 160 | deploy: |
141 | 161 | environment: |
142 | 162 | name: github-pages |
143 | 163 | url: ${{ steps.deployment.outputs.page_url }} |
144 | 164 | runs-on: ubuntu-latest |
145 | 165 | needs: |
146 | 166 | - hugo |
| 167 | + - check_liascript_changes |
147 | 168 | - liascript |
148 | 169 | - liascript-nightly |
149 | 170 | steps: |
@@ -191,6 +212,22 @@ jobs: |
191 | 212 | tar -xvf public/nightly/artifact.tar -C public/nightly |
192 | 213 | rm public/nightly/artifact.tar |
193 | 214 |
|
| 215 | + - name: Download or use cached LiaScript artifact |
| 216 | + uses: actions/cache@v2 |
| 217 | + with: |
| 218 | + path: ./public/course |
| 219 | + key: ${{ runner.os }}-liascript-${{ github.sha }} |
| 220 | + restore-keys: | |
| 221 | + ${{ runner.os }}-liascript- |
| 222 | +
|
| 223 | + - name: Download or use cached LiaScript-nightly artifact |
| 224 | + uses: actions/cache@v2 |
| 225 | + with: |
| 226 | + path: ./public/nightly |
| 227 | + key: ${{ runner.os }}-liascript-nightly-${{ github.sha }} |
| 228 | + restore-keys: | |
| 229 | + ${{ runner.os }}-liascript-nightly- |
| 230 | +
|
194 | 231 | - name: Deploy to GitHub Pages |
195 | 232 | uses: peaceiris/actions-gh-pages@v3 |
196 | 233 | with: |
|
0 commit comments