This commit is contained in:
52
.gitea/workflows/build-and-push.yml
Normal file
52
.gitea/workflows/build-and-push.yml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
name: Build and Push App Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Example: registry.example.com/your-user/noteapp
|
||||||
|
IMAGE_NAME: ${{ secrets.REGISTRY_IMAGE }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set image tags
|
||||||
|
id: vars
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
SHORT_SHA="${GITHUB_SHA::7}"
|
||||||
|
BRANCH="${GITHUB_REF_NAME//\//-}"
|
||||||
|
|
||||||
|
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.REGISTRY_HOST }}
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build and push app image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./devops/docker/Dockerfile
|
||||||
|
push: true
|
||||||
|
build-args: |
|
||||||
|
VITE_API_BASE_URL=${{ secrets.VITE_API_BASE_URL }}
|
||||||
|
tags: |
|
||||||
|
${{ env.IMAGE_NAME }}:latest
|
||||||
|
${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.short_sha }}
|
||||||
|
${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.branch }}
|
||||||
Reference in New Issue
Block a user