|
1 |
| -name: Build and Deploy |
| 1 | +name: Build and Deploy static content to GitHub Pages |
2 | 2 |
|
3 | 3 | on:
|
4 |
| - workflow_dispatch: |
5 | 4 | push:
|
6 |
| - branches: [ "master" ] |
| 5 | + branches: master |
7 | 6 | pull_request:
|
8 |
| - branches: [ "master" ] |
| 7 | + branches: master |
| 8 | + |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
9 | 11 |
|
10 | 12 | permissions:
|
11 | 13 | contents: read
|
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow one concurrent deployment |
| 18 | +concurrency: |
| 19 | + group: "pages" |
| 20 | + cancel-in-progress: true |
12 | 21 |
|
13 | 22 | jobs:
|
14 |
| - build_and_deploy: |
15 |
| - runs-on: ubuntu-latest |
16 |
| - steps: |
17 |
| - - uses: actions/checkout@v3 |
18 |
| - - name: Install dependencies |
19 |
| - run: | |
20 |
| - sudo apt-get update; |
21 |
| - sudo apt-get install --yes \ |
22 |
| - texinfo groff \ |
23 |
| - texlive-base texlive-fonts-recommended texlive-plain-generic |
24 |
| - - name: Set up Ruby |
25 |
| - uses: ruby/setup-ruby@v1 |
26 |
| - with: |
27 |
| - ruby-version: 2.7 |
28 |
| - bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
29 |
| - - name: Build website |
30 |
| - run: bundle exec middleman build |
31 |
| - - name: Build documentation |
32 |
| - run: make docs |
33 |
| - - name: Deploy |
34 |
| - if: ${{ github.ref == 'refs/heads/master' }} |
35 |
| - env: |
36 |
| - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
37 |
| - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
38 |
| - uses: reggionick/s3-deploy@v3 |
39 |
| - with: |
40 |
| - folder: build |
41 |
| - bucket: ${{ vars.AWS_S3_BUCKET }} |
42 |
| - bucket-region: ${{ vars.AWS_S3_BUCKET_REGION }} |
43 |
| - delete-removed: true |
44 |
| - no-cache: true |
45 |
| - private: true |
46 |
| - filesToInclude: ".*/*,*/*,**" |
| 23 | + build: |
| 24 | + environment: |
| 25 | + name: github-pages |
| 26 | + url: ${{ steps.deployment.outputs.page_url }} |
| 27 | + |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v3 |
| 31 | + - name: Set up Ruby |
| 32 | + uses: ruby/setup-ruby@v1 |
| 33 | + with: |
| 34 | + ruby-version: 2.7 |
| 35 | + bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
| 36 | + - name: Build website |
| 37 | + run: bundle exec middleman build |
| 38 | + |
| 39 | + - uses: cachix/install-nix-action@v20 |
| 40 | + with: |
| 41 | + nix_path: nixpkgs=channel:nixos-unstable |
| 42 | + - name: Build documentation |
| 43 | + env: |
| 44 | + OWNER: afh |
| 45 | + REPO: ledger |
| 46 | + run: | |
| 47 | + # TODO: change ledger to ${OWNER} prior to merging |
| 48 | + LATEST=$(curl -sqI -w '%{redirect_url}' -o /dev/null https://github.com/ledger/${REPO}/releases/latest | awk -F/ '{print $NF}') |
| 49 | + # TODO: remove this override prior to merging |
| 50 | + LATEST=web-docs |
| 51 | + nix build github:${OWNER}/${REPO}/${LATEST}#web-docs |
| 52 | + mkdir -p build/doc |
| 53 | + cp result/share/doc/ledger/ledger* build/doc |
| 54 | +
|
| 55 | + - name: Setup Pages |
| 56 | + uses: actions/configure-pages@v3 |
| 57 | + - name: Upload artifact |
| 58 | + uses: actions/upload-pages-artifact@v1 |
| 59 | + with: |
| 60 | + path: 'build' |
| 61 | + - name: Deploy to GitHub Pages |
| 62 | + id: deployment |
| 63 | + uses: actions/deploy-pages@v1 |
0 commit comments