|
1 | | -name: Deploy |
| 1 | +name: Test & Deploy |
2 | 2 | on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + pull_request: |
| 7 | + workflow_dispatch: |
3 | 8 | release: |
4 | | - types: [published] |
| 9 | + types: |
| 10 | + - published |
| 11 | + |
5 | 12 | jobs: |
6 | 13 | test: |
7 | | - name: Test |
8 | 14 | runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + fail-fast: false |
9 | 17 | steps: |
| 18 | + - name: Cancel Previous Runs |
| 19 | + uses: styfle/cancel-workflow-action@0.4.0 |
| 20 | + with: |
| 21 | + access_token: ${{ github.token }} |
| 22 | + |
10 | 23 | - uses: actions/checkout@v2 |
11 | 24 |
|
12 | 25 | - uses: actions/setup-node@v2 |
13 | 26 | with: |
14 | 27 | node-version: "15" |
15 | 28 | check-latest: true |
16 | 29 |
|
17 | | - - name: Cache node modules |
18 | | - uses: actions/cache@v2 |
19 | | - with: |
20 | | - path: node_modules |
21 | | - key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} |
22 | | - restore-keys: | |
23 | | - ${{ runner.OS }}-build-${{ env.cache-name }}- |
24 | | - ${{ runner.OS }}-build- |
25 | | - ${{ runner.OS }}- |
26 | | -
|
27 | 30 | - run: make envvar |
28 | 31 |
|
29 | | - # Pull the latest image to build, and avoid caching pull-only images. |
30 | | - # (docker pull is faster than caching in most cases.) |
31 | | - - run: docker-compose pull |
32 | | - |
33 | | - # In this step, this action saves a list of existing images, |
34 | | - # the cache is created without them in the post run. |
35 | | - # It also restores the cache if it exists. |
36 | | - - uses: satackey/action-docker-layer-caching@v0.0.11 |
37 | | - # Ignore the failure of a step and avoid terminating the job. |
38 | | - continue-on-error: true |
| 32 | + - run: make pull |
39 | 33 |
|
40 | 34 | - run: make image |
41 | 35 |
|
42 | 36 | - run: make test |
43 | 37 |
|
44 | 38 | deploy: |
45 | | - name: Deploy |
| 39 | + if: github.event.action == 'published' && github.repository == 'jazzband-roadies/website' |
| 40 | + |
46 | 41 | runs-on: ubuntu-latest |
| 42 | + |
47 | 43 | needs: [test] |
| 44 | + |
48 | 45 | steps: |
49 | 46 | - name: Cancel Previous Runs |
50 | 47 | uses: styfle/cancel-workflow-action@0.4.0 |
|
57 | 54 | fetch-depth: 0 |
58 | 55 |
|
59 | 56 | - name: Push |
60 | | - uses: dokku/github-action@v1 |
| 57 | + uses: dokku/github-action@v1.0.2 |
61 | 58 | # enable verbose ssh output |
62 | 59 | with: |
63 | | - # specify `--force` as a flag for git pushes |
64 | 60 | git_push_flags: "--force" |
65 | 61 | git_remote_url: ${{ secrets.SSH_REMOTE_URL }} |
66 | 62 | ssh_private_key: ${{ secrets.PRIVATE_KEY }} |
|
0 commit comments