Skip to content

Commit

Permalink
chore: add docker publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwep committed Oct 28, 2023
1 parent e1f7fd0 commit f8ef21f
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 }}

0 comments on commit f8ef21f

Please sign in to comment.