Skip to content

fix(auth): 修复CSRF cookie路径设置和错误消息格式 (#67) #110

fix(auth): 修复CSRF cookie路径设置和错误消息格式 (#67)

fix(auth): 修复CSRF cookie路径设置和错误消息格式 (#67) #110

Workflow file for this run

name: Docker Image CI
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: read
packages: write
env:
REGISTRY_IMAGE_DOCKERHUB: e1saps/shortlinker
REGISTRY_IMAGE_GHCR: ghcr.io/apts-1547/shortlinker
jobs:
build-and-push:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: true
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# with:
# platforms: arm64,386
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
buildkitd-flags: |
--allow-insecure-entitlement security.insecure
--allow-insecure-entitlement network.host
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_IMAGE_DOCKERHUB }}
${{ env.REGISTRY_IMAGE_GHCR }}
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=tag
labels: |
org.opencontainers.image.title=Shortlinker
org.opencontainers.image.description=A simple, fast, and secure URL shortener written in Rust
org.opencontainers.image.vendor=AptS-1547
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: .
# platforms: linux/amd64,linux/arm64,linux/386
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# 启用多层缓存策略
cache-from: |
type=gha
type=registry,ref=${{ env.REGISTRY_IMAGE_DOCKERHUB }}:buildcache
type=registry,ref=${{ env.REGISTRY_IMAGE_GHCR }}:buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=${{ env.REGISTRY_IMAGE_DOCKERHUB }}:buildcache,mode=max
build-args: |
VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }}
# 启用构建记录和证明
provenance: true
sbom: true
# 可选:构建总结和通知
- name: Build Summary
if: always()
run: |
echo "## Docker Build Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ github.ref_type == 'tag' && github.ref_name || github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Platforms**: linux/amd64" >> $GITHUB_STEP_SUMMARY
echo "- **Images**:" >> $GITHUB_STEP_SUMMARY
echo " - Docker Hub: ${{ env.REGISTRY_IMAGE_DOCKERHUB }}" >> $GITHUB_STEP_SUMMARY
echo " - GitHub CR: ${{ env.REGISTRY_IMAGE_GHCR }}" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY