diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..751c958 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/deployPages.yml b/.github/workflows/deployPages.yml deleted file mode 100644 index 2bfee34..0000000 --- a/.github/workflows/deployPages.yml +++ /dev/null @@ -1,46 +0,0 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages - -on: - # Runs on pushes targeting the default branch - push: - branches: ["master"] - - # 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: - # Single deploy job since we're just deploying - deploy: - 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 - uses: actions/upload-pages-artifact@v3 - with: - # Upload entire repository - path: './dist/' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file