Add GitHub Actions workflows for building and deploying application

This commit is contained in:
2025-10-01 14:11:56 +08:00
parent 24154f42d4
commit 79411d2eb3
4 changed files with 264 additions and 0 deletions

50
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Build Container Image
on:
workflow_dispatch:
inputs:
tag:
description: 'Image tag'
required: false
default: 'latest'
type: string
env:
REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}
IMAGE_NAME: ${{ secrets.IMAGE_NAME }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ inputs.tag }}
type=sha,prefix={{branch}}-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Output image tags
run: |
echo "Built and pushed image tags: ${{ steps.meta.outputs.tags }}"