2022-10-12 06:10:55 +08:00
|
|
|
name: "Build Docker"
|
2022-02-13 23:38:54 +08:00
|
|
|
|
|
|
|
on: workflow_call
|
|
|
|
jobs:
|
|
|
|
buildx:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
name: Build Docker
|
|
|
|
steps:
|
2023-07-02 18:50:29 +08:00
|
|
|
- uses: actions/checkout@24cb9080177205b6e8c946b17badbe402adc938f # v3.4.0
|
2022-02-13 23:38:54 +08:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-07-02 18:50:29 +08:00
|
|
|
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # 3.0.2
|
2022-02-13 23:38:54 +08:00
|
|
|
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
|
2022-02-13 23:38:54 +08:00
|
|
|
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') }}
|
2022-02-13 23:38:54 +08:00
|
|
|
run: |
|
2023-07-19 16:37:59 +08:00
|
|
|
echo "tag_flags=--tag ${{ github.ref }}" >> $GITHUB_ENV
|
2022-02-19 15:22:50 +08:00
|
|
|
REPO=ghcr.io/${{ github.repository }}
|
2022-02-13 23:38:54 +08:00
|
|
|
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
|
2022-02-13 23:38:54 +08:00
|
|
|
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 }} .
|