|
1 | | -name: CI |
| 1 | +name: main-deploy |
2 | 2 |
|
3 | 3 | # Controls when the workflow will run |
4 | 4 | on: |
5 | | - # Triggers the workflow on push or pull request events but only for the main branch |
| 5 | + # Triggers the workflow on push events for the main branch |
6 | 6 | push: |
7 | 7 | branches: [ main ] |
8 | | - pull_request: |
9 | | - branches: [ main ] |
10 | 8 |
|
11 | 9 | # Allows you to run this workflow manually from the Actions tab |
12 | 10 | workflow_dispatch: |
13 | 11 |
|
| 12 | +# Needs write permission to update the gh-pages branch that is used for GitHub Pages |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + |
14 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel |
15 | 17 | jobs: |
16 | | - # This workflow contains a single job called "build" |
17 | | - build: |
18 | | - # The type of runner that the job will run on |
| 18 | + # This workflow contains a single job called "deploy" |
| 19 | + # Copied from https://squidfunk.github.io/mkdocs-material/publishing-your-site/ |
| 20 | + deploy: |
19 | 21 | runs-on: ubuntu-latest |
20 | | - |
21 | | - env: |
22 | | - STPATOOLS_VERSION: "42e07abc5510f5864aa102aa7ae1e8349911a620" |
23 | | - STPATOOLS_REPO: "https://gitlab.com/CodethinkLabs/stpatools.git" |
24 | | - |
25 | | - # Steps represent a sequence of tasks that will be executed as part of the job |
26 | 22 | steps: |
27 | | - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
28 | | - - uses: actions/checkout@v2 |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + - name: Configure Git Credentials |
| 25 | + run: | |
| 26 | + git config user.name github-actions[bot] |
| 27 | + git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 28 | + - uses: actions/setup-python@v5 |
| 29 | + with: |
| 30 | + python-version: 3.x |
| 31 | + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV |
| 32 | + - uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + key: mkdocs-material-${{ env.cache_id }} |
| 35 | + path: .cache |
| 36 | + restore-keys: | |
| 37 | + mkdocs-material- |
| 38 | + - run: pip install mkdocs-material mkdocs-material-extensions pymdown-extensions |
| 39 | + - run: mkdocs gh-deploy --force |
| 40 | + |
| 41 | +name: push-preview |
29 | 42 |
|
30 | | - # Check that YAML files are well-formed |
31 | | - - name: YAML lint |
32 | | - run: yamllint -d relaxed . |
| 43 | +on: |
| 44 | + # Triggers on pull request branch when it is marked ready for review |
| 45 | + pull_request: |
| 46 | + type: [ready_for_review] |
33 | 47 |
|
34 | | - # Install specific version of ruamel.yaml required by STPAtools |
35 | | - - name: Install ruamel.yaml |
36 | | - run: pip3 install ruamel.yaml==0.16.7 |
| 48 | + # Allows you to run this workflow manually from the Actions tab |
| 49 | + workflow_dispatch: |
37 | 50 |
|
38 | | - # Install specific version of STPA tools from repo |
39 | | - - name: Install STPA tools |
40 | | - run: pip3 install "git+${{env.STPATOOLS_REPO}}@${{env.STPATOOLS_VERSION}}" |
| 51 | +# Needs write permission to update the gh-pages branch that is used for GitHub Pages |
| 52 | +permissions: |
| 53 | + contents: write |
41 | 54 |
|
42 | | - # Validate STPA files |
43 | | - - name: Validate STPA files (STPA_DynMA) |
44 | | - run: stpa-validate STPA_DynMA/*.yml |
| 55 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 56 | +jobs: |
| 57 | + # This workflow contains a single job called "preview" |
| 58 | + # This deploys PR content to a preview sub-directory |
| 59 | + deploy: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + - name: Configure Git Credentials |
| 64 | + run: | |
| 65 | + git config user.name github-actions[bot] |
| 66 | + git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 67 | + - uses: actions/setup-python@v5 |
| 68 | + with: |
| 69 | + python-version: 3.x |
| 70 | + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV |
| 71 | + - uses: actions/cache@v4 |
| 72 | + with: |
| 73 | + key: mkdocs-material-${{ env.cache_id }} |
| 74 | + path: .cache |
| 75 | + restore-keys: | |
| 76 | + mkdocs-material- |
| 77 | + - run: pip install mkdocs-material mkdocs-material-extensions pymdown-extensions |
| 78 | + - run: mkdocs gh-deploy -v -d preview/ --force |
0 commit comments