diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b1a60f..422e8da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,11 @@ name: CI on: push +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + OCULAR_GENESIS_HOST: /api + jobs: build: name: Build app @@ -25,12 +30,6 @@ jobs: run: pnpm run lint - name: Build - env: - OAUTH_URI: ${{ secrets.OAUTH_URI }} - OAUTH_SCOPE: ${{ secrets.OAUTH_SCOPE }} - OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }} - OCULAR_ACKEE_HOST: ${{ secrets.OCULAR_ACKEE_HOST }} - OCULAR_ACKEE_DOMAIN_ID: ${{ secrets.OCULAR_ACKEE_DOMAIN_ID }} run: pnpm run build - name: Upload artifact @@ -40,26 +39,40 @@ jobs: name: app path: dist - deploy: - name: Deploy app to GitHub Pages - runs-on: ubuntu-latest + build_docker: + if: startsWith(github.event.ref, 'refs/tags/v') + name: Build and publish docker image needs: build - if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - - uses: actions/checkout@v3 - - name: Download artifact - uses: actions/download-artifact@v3 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 with: - name: app - path: dist + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Pre-Deploy - run: | - cp dist/index.html dist/404.html - touch dist/.nojekyll + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + ${{ github.ref_name }} + latest - - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 + - name: Build and push Docker image + uses: docker/build-push-action@v5 with: - branch: gh-pages - folder: dist + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + OCULAR_GENESIS_HOST=${{ env.OCULAR_GENESIS_HOST }}