Skip to content

Commit

Permalink
Merge pull request #12 from CubicrootXYZ/upload-openapi-as-pages
Browse files Browse the repository at this point in the history
workflow for deploying GitHub pages
  • Loading branch information
CubicrootXYZ authored Oct 20, 2024
2 parents 3d1db51 + dada5b9 commit 4dcae76
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
workflow_call:
inputs:
artifact_name:
required: true
type: string
artifact_path:
required: true
type: string

jobs:
deploy:
if: "${{ github.ref == 'refs/heads/main' }}"
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@master
with:
name: "{{ inputs.artifact_name }}"
path: "{{ inputs.artifact_path }}"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
24 changes: 24 additions & 0 deletions .github/workflows/pages_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on: push

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

jobs:
pages_test_prep:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3
- uses: actions/upload-artifact@master
with:
name: static-html
path: tests/pages/index.html
pages_test:
needs:
- pages_test_prep
uses: ./.github/workflows/pages.yaml
with:
artifact_name: static-html
artifact_path: tests/pages/index.html
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,28 @@ jobs:
with:
entrypoint: cmd/main.go
workdir: ./
```

## GitHub Pages

Make sure GitHub pages are activated and set to "GitHub Action" in your repository settings.

Add the following permissions to the `workflows` file:

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

To deploy an artifact to GitHub pages use the following job:

```yaml
jobs:
pages_test:
uses: CubicrootXYZ/Workflows/.github/workflows/pages.yaml
with:
artifact_name: static-html
artifact_path: index.html
```
7 changes: 7 additions & 0 deletions tests/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>

<body>
<h1>Hello World</h1>
</body>

</html>

0 comments on commit 4dcae76

Please sign in to comment.