ci: publish package if main branch #155
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ImplementationGuide Publisher | |
# Controls when the action will run. | |
on: | |
# Triggers the workflow on push or pull request events but only for the main or master branch | |
push: | |
branches: | |
- main | |
- master | |
- staging | |
- 'v[0-9]+.[0-9]+*' # Approximates v[0-9]+.[0-9]+.* pattern | |
tags: | |
- 'v[0-9]+.[0-9]+*' # Trigger for semantic version tags (e.g., v1.2, v1.2.3) | |
- 'v[0-9]+.[0-9]+.*-*' # Additional pattern for pre-release versions (e.g., v1.2.3-snapshot) | |
pull_request: | |
branches: | |
- main | |
- master | |
- staging | |
- 'v[0-9]+.[0-9]+*' # Approximates v[0-9]+.[0-9]+.* pattern | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
run-publisher: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
# read id, version and canonical from sushi-config.yaml | |
- name: Run read-yaml action | |
id: yaml-data | |
uses: CumulusDS/[email protected] | |
with: | |
file: sushi-config.yaml | |
version: version | |
canonical: canonical | |
id: id | |
# display outputs from read-yaml action | |
- name: Display read-yaml output | |
run: | | |
echo "id: ${{ steps.yaml-data.outputs.id }}" | |
echo "target url: ${{ steps.yaml-data.outputs.canonical }}" | |
echo "version: ${{ steps.yaml-data.outputs.version }}" | |
- name: Run the IG publisher | |
uses: docker://hl7fhir/ig-publisher-base:latest | |
with: | |
args: ./scripts/run-ig-publisher.sh | |
# deploy implementation guide to github pages | |
- name: Deploy | |
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./output | |
force_orphan: true | |
# upload binaries to release | |
- name: Upload binaries to release | |
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./output/package.tgz | |
asset_name: ${{ steps.yaml-data.outputs.id }}-${{ steps.yaml-data.outputs.version }}.tgz | |
tag: v${{ steps.yaml-data.outputs.version }} | |
release_name: Release v${{ steps.yaml-data.outputs.version }} | |
overwrite: true |