diff --git a/.github/workflows/automation.yml b/.github/workflows/automation.yml new file mode 100644 index 0000000..018c638 --- /dev/null +++ b/.github/workflows/automation.yml @@ -0,0 +1,72 @@ +name: GitHub Pages + +on: + push: + branches: + - main + +jobs: + release-project: + name: Release static site to github releases + runs-on: ubuntu-latest + needs: deploy + steps: + - name: Download site content + uses: actions/download-artifacts@v2 + with: + name: static-site + - name: Archive site content + uses: thedoctor0/zip-release@main + with: + filename: site.zip + - name: create Github Release + id: create-new-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ github.run_number }} + release_name: Release V${{ github.run_number }} + - name: Upload asset to Github Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} + with: + upload_url: ${{ steps.create-new-release.outputs.upload_url }} + asset_path: ./site.zip + asset_name: site-v${{ github.run_number }}.zip + asset_content_type: application/zip + + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm run test:headless + + - name: Build + run: npm run build:prod + + - name: Upload static website + uses: actions/upload-artifact@v2 + with: + name: static-site + path: out/ + + - name: Deploy + if: success() + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: dist/angular-github-actions + enable_jekyll: true