70 lines
1.8 KiB
YAML
70 lines
1.8 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- testing
|
|
- pre-release
|
|
- alpha
|
|
- beta
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag_name:
|
|
description: "Custom tag name for the Docker image"
|
|
required: false
|
|
default: ""
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Node.js for Building Frontend
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Install Dependencies and Build Frontend
|
|
run: |
|
|
cd frontend
|
|
npm install
|
|
npm run build
|
|
|
|
- name: Setup Docker Buildx
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v1
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Lowercase repository owner
|
|
id: lowercase_repo_owner
|
|
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
|
|
|
- name: Determine Docker image tag
|
|
id: tag
|
|
run: |
|
|
if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag_name }}" ]; then
|
|
echo "IMAGE_TAG=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
|
|
else
|
|
echo "IMAGE_TAG=${{ github.run_id }}" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Build and Push Docker image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
file: ./docker/Dockerfile
|
|
push: true
|
|
tags: ghcr.io/${{ env.REPO_OWNER }}/ssh-project:${{ env.IMAGE_TAG }}
|
|
|
|
- name: Post-build clean-up
|
|
run: docker system prune -af |