Improve readme #2
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: Build and Deploy | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["master"] | |
release: | |
types: [published] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
# deploy docker to github registry | |
deployDocker: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Packages | |
uses: docker/login-action@v1 | |
with: | |
registry: docker.pkg.github.com | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: docker.pkg.github.com/${{ github.repository }}/anser-static:${{ github.sha }} | |
# deploy static | |
deployStatic: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build | |
run: | | |
bash build.sh | |
# Deploy to GitHub action artifacts | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: anser-static-snapshot | |
path: "./dist/" | |
# Deploy to GitHub Releases | |
- name: Compress dist | |
if: github.event_name == 'release' | |
run: | | |
cd dist | |
zip -r ../anser-static-deploy.zip www | |
cd .. | |
- name: "Upload to github releases" | |
if: github.event_name == 'release' | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./anser-static-deploy.zip | |
asset_name: anser-static-deploy.zip | |
asset_content_type: application/zip | |
# deploy static | |
deployPages: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Build | |
run: | | |
bash build.sh | |
- name: Upload artifact | |
if: github.event_name == 'release' | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: "./dist/" | |
- name: Deploy to GitHub Pages | |
if: github.event_name == 'release' | |
id: deployment | |
uses: actions/deploy-pages@v4 |