Skip to content

Build web component outside of docker build (#580) #17

Build web component outside of docker build (#580)

Build web component outside of docker build (#580) #17

Workflow file for this run

name: Releases
on:
push:
tags:
- "v*"
jobs:
release:
name: Release on GitHub
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Publish Release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
})
let releaseId = null;
for (const release of releases) {
if (release.draft) {
releaseId = release.id
break
}
}
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseId,
tag_name: '${{ github.ref_name }}',
name: 'Release ${{ github.ref_name }}',
draft: context.eventName != 'push'
})
release-docker:
name: Release on Docker Hub
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
# When building for arm/v7, npm install will fail
# so let's build the frontend outside of the docker build
- name: Build frontend
run: make web
- name: Get build variables
run: |
echo "BUILD_COMMIT=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
echo "BUILD_VERSION=$(git describe --tags --always)" >> $GITHUB_ENV
- name: Check build variables
run: |
echo $BUILD_COMMIT
echo $BUILD_DATE
echo $BUILD_VERSION
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
harryzcy/mailbox-browser
ghcr.io/harryzcy/mailbox-browser
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
build-args: |
BUILD_DATE=${{ env.BUILD_DATE }}
BUILD_COMMIT=${{ env.BUILD_COMMIT }}
BUILD_VERSION=${{ env.BUILD_VERSION }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}