feat(ci): move rust docker target bash to shell script

This commit is contained in:
alyssa 2024-10-25 03:27:58 +09:00
parent 79f7c973e7
commit 124da02a42
5 changed files with 139 additions and 19 deletions

View file

@ -12,8 +12,8 @@ on:
- 'services/gateway/**'
- 'services/avatars/**'
- '.github/workflows/rust.yml'
- 'Dockerfile.rust'
- 'Dockerfile.bin'
- 'ci/Dockerfile.rust'
- 'ci/rust-docker-target.sh'
- 'Cargo.toml'
- 'Cargo.lock'
@ -40,7 +40,7 @@ jobs:
with:
# https://github.com/docker/build-push-action/issues/378
context: .
file: Dockerfile.rust
file: ci/Dockerfile.rust
push: false
cache-from: type=registry,ref=ghcr.io/pluralkit/docker-cache:rust
cache-to: type=registry,ref=ghcr.io/pluralkit/docker-cache:rust,mode=max
@ -48,13 +48,7 @@ jobs:
# add more binaries here
- run: |
for binary in "api" "gateway" "avatars"; do
for tag in latest ${{ env.BRANCH_NAME }} ${{ github.sha }}; do
cat Dockerfile.bin | sed "s/__BINARY__/$binary/g" | docker build -t ghcr.io/pluralkit/$binary:$tag -f - .
done
if [ "${{ github.repository }}" == "PluralKit/PluralKit" ]; then
docker push ghcr.io/pluralkit/$binary:${{ env.BRANCH_NAME }}
docker push ghcr.io/pluralkit/$binary:${{ github.sha }}
[ "${{ env.BRANCH_NAME }}" == "main" ] && docker push ghcr.io/pluralkit/$binary:latest
fi
done
tag=${{ github.sha }} \
branch=${{ env.BRANCH_NAME }} \
push=$([ "${{ github.repository }}" == "PluralKit/PluralKit" ] && echo true || echo false) \
ci/rust-docker-target.sh