Build and publish Github image #26
Workflow file for this run
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 and publish Github image | |
on: | |
release: | |
types: [released] | |
pull_request: | |
types: [closed] | |
branches: [ master ] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build image | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Set env variables | |
run: | | |
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
echo "IMAGE_NAME=$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout project | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Get version from package.json | |
id: package-version | |
run: | | |
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
echo "Image Name: $IMAGE_NAME" | |
echo "Branch Name: $BRANCH" | |
echo "Project Version: $VERSION" | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
id: qemu | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
id: buildx | |
- name: Run Docker buildx | |
run: | | |
docker buildx build \ | |
--platform linux/amd64,linux/arm64,linux/arm/v7 \ | |
--tag ghcr.io/$IMAGE_NAME:$VERSION \ | |
--output "type=registry" . |