Update caching & docker compose

This commit is contained in:
yuanhau 2025-05-18 16:11:07 +08:00
parent 8975812447
commit bd7ac3367f
5 changed files with 68 additions and 73 deletions

View file

@ -0,0 +1,53 @@
name: Build and Push Docker Image
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha,prefix=
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- 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 }}
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -1,34 +0,0 @@
name: Server Deployment Request
on:
push:
branches:
- master
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
env:
DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
steps:
- name: Send deployment request
id: deploy-request
run: |
echo "Sending deployment request to server..."
RESPONSE=$(curl -X POST \
-H "Content-Type: application/json" \
--http1.1 \
--fail \
--silent \
--show-error \
"${{ secrets.DEPLOY_URL }}" || echo "Failed to send request")
if [ $? -eq 0 ]; then
echo "Deployment request sent successfully"
echo "Response: $RESPONSE"
else
echo "Error sending deployment request"
exit 1
fi