68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
name: Build and Push Backend to Aliyun ACR
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Image version tag, for example v0.1.0-test.1"
|
|
required: true
|
|
type: string
|
|
|
|
env:
|
|
REGISTRY: ${{ secrets.ALIYUN_REGISTRY }}
|
|
NAMESPACE: ${{ secrets.ALIYUN_NAME_SPACE }}
|
|
ALIYUN_REGISTRY_USER: ${{ secrets.ALIYUN_REGISTRY_USER }}
|
|
ALIYUN_REGISTRY_PASSWORD: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
|
|
|
|
jobs:
|
|
build-backend:
|
|
name: Build and push Rust backend
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Aliyun ACR
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
echo "$ALIYUN_REGISTRY_PASSWORD" | docker login \
|
|
--username "$ALIYUN_REGISTRY_USER" \
|
|
--password-stdin "$REGISTRY"
|
|
|
|
- name: Prepare image tags
|
|
id: prep
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
VERSION="${{ inputs.version || github.ref_name }}"
|
|
IMAGE="${REGISTRY}/${NAMESPACE}/email-unlimit-server"
|
|
SHORT_SHA="${GITHUB_SHA::7}"
|
|
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Build and push backend
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
docker buildx build \
|
|
--platform linux/amd64 \
|
|
--provenance=false \
|
|
--cache-from=type=gha,scope=email-unlimit-server \
|
|
--cache-to=type=gha,mode=max,scope=email-unlimit-server \
|
|
-t "${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.version }}" \
|
|
-t "${{ steps.prep.outputs.image }}:sha-${{ steps.prep.outputs.short_sha }}" \
|
|
-t "${{ steps.prep.outputs.image }}:latest" \
|
|
--push \
|
|
-f server/Dockerfile \
|
|
server
|