Skip to content

Build and Deploy

Build and Deploy #93

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- main
pull_request:
types: [synchronize, opened]
schedule:
- cron: '15 2 * * *' # Every day at midnight UTC
jobs:
Build:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ghcr.io/alchemycms/alchemy-demo
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Expose GitHub Runtime for cache
uses: crazy-max/ghaction-github-runtime@v3
- name: Set Alchemy Version
run: |
version=$(awk '/^ alchemy_cms \(/ { gsub(/[()]/, "", $2); print $2 }' "Gemfile.lock")
echo "ALCHEMY_VERSION=$version" >> "$GITHUB_ENV"
- name: Show Alchemy Version
run: echo "Current Alchemy Version ${{ env.ALCHEMY_VERSION }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: $
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.IMAGE_NAME }}:${{ env.ALCHEMY_VERSION }}
${{ env.IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
Deploy:
runs-on: ubuntu-latest
needs: Build
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
environment:
name: alchemy-demo
url: https://demo.alchemy-cms.com
steps:
- name: Deploy the app
uses: digitalocean/app_action/deploy@v2
with:
token: ${{ secrets.DO_DEPLOY_TOKEN }}
app_name: alchemy-demo