mirror of
https://github.com/Yorgei/docker-compose.git
synced 2025-11-08 13:33:27 +00:00
Create node-build-push.yaml
This commit is contained in:
63
.gitea/workflows/node-build-push.yaml
Normal file
63
.gitea/workflows/node-build-push.yaml
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Default for node apps.
|
||||||
|
name: Build and Push Docker Image
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main # Trigger on pushes to the main branch
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
# Use a runner label defined in your runner's environment variables
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GIT_SSL_NO_VERIFY: "1"
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
# Optional: Login step if your registry requires authentication
|
||||||
|
- name: Log in to local registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.REGISTRY_URL }} # Use the same IP as in daemon.json
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }} # Store credentials in Gitea secrets
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }} # Store credentials in Gitea secrets
|
||||||
|
|
||||||
|
- name: Determine Image Tag
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
# Use Git tag if present, otherwise use 'latest' for default branch
|
||||||
|
if [[ ${GITHUB_REF} == refs/tags/* ]]; then
|
||||||
|
TAG=${GITHUB_REF#refs/tags/}
|
||||||
|
else
|
||||||
|
TAG=latest
|
||||||
|
fi
|
||||||
|
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||||
|
echo "Using tag: ${TAG}"
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
# IMPORTANT: Tag format is REGISTRY_HOST:PORT/IMAGE_NAME:TAG
|
||||||
|
tags: ${{ secrets.REGISTRY_URL }}/${{ github.repository }}:${{ steps.meta.outputs.tag }}
|
||||||
|
# Optional: Add build arguments
|
||||||
|
# build-args: |
|
||||||
|
# ARG_NAME=value
|
||||||
|
cache-from: type=gha # Optional: Enable build cache
|
||||||
|
cache-to: type=gha,mode=max # Optional: Enable build cache
|
||||||
|
|
||||||
|
- name: Send webhook notification
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
status_code=$(curl -s -o /dev/null -w "%{http_code}" \
|
||||||
|
-X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"status": "${{ job.status }}", "repo":"${{ github.repository }}"}' \
|
||||||
|
${{ secrets.WEBHOOK_URL }})
|
||||||
|
echo "Webhook HTTP status code: $status_code"
|
||||||
Reference in New Issue
Block a user