Build Docker Image & Deploy to Vercel #51
This file contains 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 Docker Image & Deploy to Vercel | |
on: | |
workflow_run: | |
workflows: ['Publish NPM Packages'] | |
types: | |
- completed | |
env: | |
UI_REGISTRY: ghcr.io | |
UI_IMAGE_NAME: ${{ github.repository }}/ui | |
jobs: | |
build-and-push: | |
name: Build and Push Image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Version | |
id: get_version | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 9 | |
- name: Update Dependencies and Install | |
run: | | |
pnpm up @lecca-io/apps@${{ env.VERSION }} @lecca-io/toolkit@${{ env.VERSION }} | |
pnpm install --frozen-lockfile | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.UI_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker image | |
env: | |
VERSION: ${{ github.ref_name }} | |
run: | | |
docker build -t ${{ env.UI_REGISTRY }}/${{ env.UI_IMAGE_NAME }}:$VERSION -f packages/ui/Dockerfile . | |
docker tag ${{ env.UI_REGISTRY }}/${{ env.UI_IMAGE_NAME }}:$VERSION ${{ env.UI_REGISTRY }}/${{ env.UI_IMAGE_NAME }}:latest | |
docker push ${{ env.UI_REGISTRY }}/${{ env.UI_IMAGE_NAME }}:$VERSION | |
docker push ${{ env.UI_REGISTRY }}/${{ env.UI_IMAGE_NAME }}:latest | |
deploy-to-vercel: | |
name: Deploy to Vercel | |
needs: build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get Version | |
id: get_version | |
run: | | |
VERSION=$(node -p "require('./package.json').version") | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Deploy to Vercel | |
uses: amondnet/vercel-action@v20 | |
env: | |
VERSION: ${{ env.VERSION }} | |
with: | |
vercel-token: ${{ secrets.VERCEL_TOKEN }} | |
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} | |
vercel-args: '--prod --build-env VERSION=${{ env.VERSION }}' |