98 lines
3.1 KiB
YAML
98 lines
3.1 KiB
YAML
name: Build Infrastructure Images
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- infrastructure
|
|
- infra-*
|
|
|
|
env:
|
|
GO_VERSION: "~1.26.0"
|
|
CGO_ENABLED: "0"
|
|
BUILD_USER: docker
|
|
BUILD_HOST: github.syncthing.net
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
id-token: write
|
|
|
|
jobs:
|
|
docker-syncthing:
|
|
name: Build and push Docker images
|
|
if: github.repository_owner == 'syncthing'
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
pkg:
|
|
- stcrashreceiver
|
|
- strelaypoolsrv
|
|
- stupgrades
|
|
- ursrv
|
|
steps:
|
|
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # was: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # was: actions/setup-go@v6
|
|
with:
|
|
go-version: ${{ env.GO_VERSION }}
|
|
check-latest: true
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build binaries
|
|
run: |
|
|
for arch in arm64 amd64; do
|
|
go run build.go -goos linux -goarch "$arch" build ${{ matrix.pkg }}
|
|
mv ${{ matrix.pkg }} ${{ matrix.pkg }}-linux-"$arch"
|
|
done
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
|
|
|
|
- name: Set Docker tags (all branches)
|
|
run: |
|
|
tags=docker.io/syncthing/${{ matrix.pkg }}:${{ github.sha }},ghcr.io/syncthing/infra/${{ matrix.pkg }}:${{ github.sha }}
|
|
echo "TAGS=$tags" >> $GITHUB_ENV
|
|
|
|
- name: Set Docker tags (latest)
|
|
if: github.ref == 'refs/heads/infrastructure'
|
|
run: |
|
|
tags=docker.io/syncthing/${{ matrix.pkg }}:latest,ghcr.io/syncthing/infra/${{ matrix.pkg }}:latest,${{ env.TAGS }}
|
|
echo "TAGS=$tags" >> $GITHUB_ENV
|
|
|
|
- name: Build and push
|
|
id: build
|
|
uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.${{ matrix.pkg }}
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ env.TAGS }}
|
|
labels: |
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
|
|
- name: Install Cosign
|
|
if: github.ref == 'refs/heads/infrastructure'
|
|
uses: sigstore/cosign-installer@ba7bc0a3fef59531c69a25acd34668d6d3fe6f22 # v4.1.0
|
|
|
|
- name: Sign image
|
|
if: github.ref == 'refs/heads/infrastructure'
|
|
run: cosign sign --yes --recursive ghcr.io/syncthing/infra/${{ matrix.pkg }}:latest@${{ steps.build.outputs.digest }} |