81 lines
2.3 KiB
YAML
81 lines
2.3 KiB
YAML
name: Build Bridge Proxy
|
|
|
|
on:
|
|
push:
|
|
branches: [main, master]
|
|
paths:
|
|
- bridge-proxy/**
|
|
- .github/workflows/bridge-proxy.yml
|
|
pull_request:
|
|
branches: [main, master]
|
|
paths:
|
|
- bridge-proxy/**
|
|
- .github/workflows/bridge-proxy.yml
|
|
|
|
env:
|
|
REGISTRY: ${{ github.server_url == 'https://github.com' && 'ghcr.io' || 'git.ipao.vip' }}
|
|
IMAGE_NAME: ${{ github.repository }}/bridge-proxy
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: bridge-proxy
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: bridge-proxy/go.mod
|
|
cache-dependency-path: bridge-proxy/go.mod
|
|
|
|
- name: Test
|
|
run: go test ./...
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to container registry
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.server_url == 'https://github.com' && github.actor || github.repository_owner }}
|
|
password: ${{ github.server_url == 'https://github.com' && secrets.GITHUB_TOKEN || secrets.PACKAGE_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
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=semver,pattern={{major}}.{{minor}}
|
|
type=sha,prefix=sha-
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./bridge-proxy
|
|
file: ./bridge-proxy/Dockerfile
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|