Skip to content

Commit

Permalink
Improve buildscript
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jan 2, 2024
1 parent ac3ccac commit c39c9de
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 46 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
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
46 changes: 0 additions & 46 deletions .github/workflows/deployPages.yml

This file was deleted.

0 comments on commit c39c9de

Please sign in to comment.