|
4 | 4 | branches: |
5 | 5 | - dev |
6 | 6 | - main |
| 7 | + |
7 | 8 | jobs: |
8 | 9 | docker: |
9 | | - name: Build Mkdocs site from docker container |
| 10 | + name: Build Mkdocs site |
10 | 11 | runs-on: ubuntu-latest |
11 | 12 | steps: |
12 | | - - name: Checkout dev branch |
13 | | - if: endsWith(github.ref, '/dev') |
14 | | - uses: actions/checkout@v2 |
15 | | - with: |
16 | | - ref: dev |
17 | | - fetch-depth: 0 |
18 | | - - name: Checkout main branch |
19 | | - if: endsWith(github.ref, '/main') |
20 | | - uses: actions/checkout@v2 |
| 13 | + - name: Checkout code |
| 14 | + uses: actions/checkout@v4 |
21 | 15 | with: |
22 | | - ref: main |
23 | 16 | fetch-depth: 0 |
24 | | - - name: Setup git config |
25 | | - run: | |
26 | | - git config user.name "GitHub Actions Bot" |
27 | | - git config user.email "<>" |
28 | | - - name: Build docker image |
| 17 | + |
| 18 | + - name: Set up Docker Buildx |
| 19 | + uses: docker/setup-buildx-action@v3 |
| 20 | + |
| 21 | + - name: Build local docker image |
29 | 22 | uses: docker/build-push-action@v2 |
30 | 23 | with: |
31 | 24 | context: . |
32 | | - push: false |
| 25 | + load: true |
33 | 26 | tags: app:latest |
| 27 | + |
34 | 28 | - name: Run mkdocs build via docker |
35 | 29 | uses: addnab/docker-run-action@v3 |
36 | 30 | with: |
37 | 31 | image: app:latest |
38 | | - options: --rm -v ${{ github.workspace }}:/docs -v ${{ github.workspace }}/site:/site |
| 32 | + options: --rm -v ${{ github.workspace }}:/docs |
39 | 33 | run: | |
40 | | - git config --global --add safe.directory /docs; |
41 | | - mkdocs build; |
42 | | - - name: Commit dev updates to site/staging branch |
| 34 | + git config --global --add safe.directory /docs |
| 35 | + mkdocs build |
| 36 | +
|
| 37 | + - name: Deploy to site/staging (from dev) |
43 | 38 | if: endsWith(github.ref, '/dev') |
44 | 39 | run: | |
45 | | - sudo chown -R runner:docker site; |
46 | | - git stash -u; |
47 | | - git fetch; |
48 | | - git switch site/staging; |
49 | | - rm -rf site; |
50 | | - git clean -d -x -f; |
51 | | - git stash pop; |
52 | | - git add .; |
53 | | - git commit -m 'Gitbot actions site change'; |
54 | | - git push origin; |
55 | | - - name: Commit main updates to site/production branch |
| 40 | + git config user.name "Github Actions Bot" |
| 41 | + git config user.email "<>" |
| 42 | + sudo chown -R $USER:$USER site |
| 43 | + git fetch origin site/staging |
| 44 | + git switch site/staging |
| 45 | + rm -rf ./* |
| 46 | + cp -r site/* . |
| 47 | + rm -rf site |
| 48 | + git add . |
| 49 | + git commit -m "Deploy dev build to staging" |
| 50 | + git push origin site/staging |
| 51 | +
|
| 52 | + - name: Deploy to site/production (from main) |
56 | 53 | if: endsWith(github.ref, '/main') |
57 | 54 | run: | |
58 | | - sudo chown -R runner:docker site; |
59 | | - git stash -u; |
60 | | - git fetch; |
61 | | - git switch site/production; |
62 | | - rm -rf site; |
63 | | - git clean -d -x -f; |
64 | | - git stash pop; |
65 | | - git add .; |
66 | | - git commit -m 'Gitbot actions site change'; |
67 | | - git push origin; |
68 | | - |
| 55 | + git config user.name "Github Actions Bot" |
| 56 | + git config user.email "<>" |
| 57 | + sudo chown -R $USER:$USER site |
| 58 | + git fetch origin site/production |
| 59 | + git switch site/production |
| 60 | + rm -rf ./* |
| 61 | + cp -r site/* . |
| 62 | + rm -rf site |
| 63 | + git add . |
| 64 | + git commit -m "Deploy main build to production" |
| 65 | + git push origin site/production |
0 commit comments