shiori/.github/workflows/_buildx.yml

54 lines
2 KiB
YAML
Raw Permalink Normal View History

name: "Build Docker"
on: workflow_call
jobs:
buildx:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Build Docker
steps:
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
with:
fetch-depth: 0
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2
with:
name: dist
- name: Prep binaries
working-directory: .github/workflows/docker
run: |
mkdir binaries
cp -r ../../../shiori_linux_* binaries/
mv binaries/shiori_linux_arm_7 binaries/shiori_linux_arm
2022-05-27 01:23:03 +08:00
mv binaries/shiori_linux_amd64_v1 binaries/shiori_linux_amd64
gzip -d -S binaries/.gz__ -r .
chmod 755 binaries/shiori_linux_*/shiori
2023-07-19 16:37:59 +08:00
- name: Prepare master push tags
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
2023-07-19 16:37:59 +08:00
echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV
REPO=ghcr.io/${{ github.repository }}
TAG=$(git describe --tags)
if [ -z "$(git tag --points-at HEAD)" ]
then
TAG2="dev"
else
TAG2="latest"
fi
2023-07-19 16:37:59 +08:00
echo "tag_flags=--tag $REPO:$TAG --tag $REPO:$TAG2" >> $GITHUB_ENV
- name: Prepare pull request tags
2023-07-19 17:42:11 +08:00
if: github.event_name == 'pull_request'
2023-07-19 16:37:59 +08:00
run: |
echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV
REPO=ghcr.io/${{ github.repository }}
2023-07-19 17:45:52 +08:00
echo "tag_flags=--tag $REPO:pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV
2023-07-19 16:37:59 +08:00
- name: Buildx
working-directory: .github/workflows/docker
run: |
set -x
echo "${{ secrets.GITHUB_TOKEN }}" | docker login -u "${{ github.repository_owner }}" --password-stdin ghcr.io
docker buildx create --use --name builder
2023-07-19 18:10:16 +08:00
docker buildx build -f Dockerfile.ci --platform=linux/amd64,arm64,linux/arm/v7 --push ${{ env.tag_flags }} .