Merge branch 'amogus' into sus #267
This file contains hidden or 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 | |
| on: | |
| push: | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Fetch main branch | |
| run: git fetch origin amogus:amogus | |
| continue-on-error: true | |
| - name: Setup Deno | |
| uses: denoland/setup-deno@v1 | |
| - name: Run Deno lint | |
| run: deno lint | |
| id: lint | |
| continue-on-error: true | |
| - name: Set check status | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [ "${{ steps.lint.outcome }}" == "success" ]; then | |
| conclusion="success" | |
| else | |
| conclusion="failure" | |
| fi | |
| gh api --method POST /repos/${{ github.repository }}/check-runs \ | |
| -f name="Deno Lint" \ | |
| -f head_sha="${{ github.sha }}" \ | |
| -f status="completed" \ | |
| -f conclusion="$conclusion" \ | |
| -f output.title="Deno Lint Results" \ | |
| -f output.summary="Deno lint completed with $conclusion." | |
| # if ok: build and deploy | |
| - name: Setup Docker Buildx | |
| if: ${{ steps.lint.outcome == 'success' }} | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Login to ghcr.io | |
| if: ${{ steps.lint.outcome == 'success' }} | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| if: ${{ (github.ref == 'refs/heads/amogus' || github.ref == 'refs/heads/sus') && steps.lint.outcome == 'success' }} | |
| uses: docker/build-push-action@v3 | |
| with: | |
| push: true | |
| tags: ghcr.io/0d9e-tech/web:${{ github.ref == 'refs/heads/amogus' && 'staging' || 'latest' }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Deploy | |
| if: ${{ (github.ref == 'refs/heads/amogus' || github.ref == 'refs/heads/sus') && steps.lint.outcome == 'success' }} | |
| run: | | |
| curl --fail-with-body --no-progress-meter -i https://0d9e.tech/deploy -X POST \ | |
| -H "x-token: ${{ github.ref == 'refs/heads/amogus' && secrets.STAGING_TOKEN || secrets.DEPLOY_TOKEN }}" | |
| # else: revert the commit(s) | |
| - name: Revert commit(s) | |
| if: ${{ steps.lint.outcome != 'success' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -e | |
| before=${{ github.event.before }} | |
| if [ "$before" = "0000000000000000000000000000000000000000" ]; then | |
| before=$(git merge-base amogus HEAD) | |
| fi | |
| gh api \ | |
| --method POST \ | |
| /repos/${{ github.repository }}/commits/${{ github.sha }}/comments \ | |
| -f 'body=Bruh, learn to code' | |
| git reset --hard $before | |
| git push origin HEAD:${{ github.ref }} --force |