Skip to content

feat: Bundler Workflow #1

feat: Bundler Workflow

feat: Bundler Workflow #1

Workflow file for this run

name: Build and Publish Bundler
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allow manual trigger
workflow_dispatch:
# Run monthly to keep the image updated
schedule:
- cron: '0 0 1 * *' # Run on the 1st of every month
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
- name: Install dependencies
run: yarn install
- name: Build dependencies
run: yarn build:deps
- name: Build Sandpack
run: yarn build:sandpack
# Create a zip archive of the www folder
- name: Create Zip Archive
run: |
cd www
zip -r ../bundler.zip .
cd ..
echo "Created bundler.zip ($(du -h bundler.zip | cut -f1) in size)"
# Upload the zip as an artifact
- name: Upload Zip Archive
uses: actions/upload-artifact@v3
with:
name: bundler-files
path: bundler.zip
retention-days: 90
# Create a release if this is a tag or manually triggered
- name: Create Release
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
id: create_release
uses: softprops/action-gh-release@v1
with:
files: bundler.zip
name: Bundler Build ${{ github.run_number }}
tag_name: bundler-v${{ github.run_number }}
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/bundler
tags: |
type=raw,value=latest
type=sha,format=short
type=schedule,pattern={{date 'YYYYMMDD'}}
# Build Docker image from the www directory (reusing the build)
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.bundler
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update deployment status
run: |
echo "Docker image built and pushed: ghcr.io/${{ github.repository }}/bundler:latest"
echo "Image SHA tag: ghcr.io/${{ github.repository }}/bundler:sha-$(git rev-parse --short HEAD)"
echo "Zip archive is available as a build artifact and in the latest release"