Skip to content

Commit

Permalink
Test pull-request deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Nov 4, 2023
1 parent 7db4a7f commit 7cd75e9
Showing 1 changed file with 80 additions and 27 deletions.
107 changes: 80 additions & 27 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,100 @@
# Auto-generated by Cimas: Do not edit it manually!
# See https://github.com/metanorma/cimas
name: docker

on:
push:
branches: [ main ]
branches: [ master, main ]
pull_request:
types:
- opened
- reopened
- synchronize
- closed
paths-ignore:
- .gitlab-ci.yml
- .github/workflows/test.yml
- .github/workflows/generate.yml
- .github/workflows/automerge.yml
repository_dispatch:
types: [ metanorma/metanorma-docker ]
workflow_dispatch:

concurrency:
group: '${{ github.workflow }}-${{ github.head_ref || github.ref_name }}'
cancel-in-progress: true

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
pull-requests: write

jobs:
build:
if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
container:
image: metanorma/metanorma:latest
image: metanorma/metanorma # ${{ inputs.docker-image }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Metanorma generate site
uses: actions-mn/build-and-publish@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
agree-to-terms: true

deploy:
if: ${{ github.ref_name == github.event.repository.default_branch }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
- uses: actions/checkout@v3
with:
token: ${{ secrets.pat_token || github.token }}
submodules: true

- name: Metanorma generate site
uses: actions-mn/build-and-publish@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

deploy-gh-pages:
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} # inputs.deploy-gh-pages == 'true' &&
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
- uses: actions/checkout@v3
with:
token: ${{ secrets.pat_token || github.token }}
- uses: actions/download-artifact@v3
with:
name: github-pages
path: site
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
branch: gh-pages
clean-exclude: pr-preview
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

deploy-gh-pages-preview:
if: ${{ github.event_name == 'pull_request' }} # inputs.deploy-gh-pages == 'true' &&
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.pat_token || github.token }}
- uses: actions/download-artifact@v3
with:
name: github-pages
path: site
- uses: rossjrw/pr-preview-action@v1
with:
source-dir: site
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

deploy-gh-pages-cleanup:
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }} # inputs.deploy-gh-pages == 'true' &&
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.pat_token || github.token }}
- uses: rossjrw/pr-preview-action@v1
with:
source-dir: .
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

0 comments on commit 7cd75e9

Please sign in to comment.