ci: Improve workflow with better checkout and timeout
This commit is contained in:
parent
b5d3c78b44
commit
0394ae989e
1 changed files with 10 additions and 9 deletions
|
|
@ -12,16 +12,19 @@ env:
|
|||
jobs:
|
||||
build-and-push:
|
||||
runs-on: synology-runner
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
run: |
|
||||
git clone https://git.khoavo.myds.me/vndangkhoa/monochrome.git /workspace/monochrome
|
||||
cd /workspace/monochrome
|
||||
git checkout $GITHUB_SHA
|
||||
if [ -d "/workspace/monochrome" ]; then
|
||||
rm -rf /workspace/monochrome
|
||||
fi
|
||||
git clone --depth 1 https://git.khoavo.myds.me/vndangkhoa/monochrome.git /workspace/monochrome
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
run: docker buildx create --name mybuilder --use || docker buildx use mybuilder
|
||||
run: |
|
||||
docker buildx create --name mybuilder --use 2>/dev/null || docker buildx use mybuilder
|
||||
|
||||
- name: Login to Forgejo Container Registry
|
||||
run: |
|
||||
|
|
@ -30,8 +33,6 @@ jobs:
|
|||
- name: Build and push Docker image
|
||||
run: |
|
||||
cd /workspace/monochrome
|
||||
TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$(echo $GITHUB_SHA | cut -c1-8)"
|
||||
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
|
||||
TAG="$TAG ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:latest"
|
||||
fi
|
||||
docker buildx build --platform linux/amd64 -t $TAG -f docker/Dockerfile --push .
|
||||
COMMIT_SHA=$(git rev-parse HEAD)
|
||||
TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${COMMIT_SHA:0:8}"
|
||||
docker buildx build --platform linux/amd64 -t $TAG -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:latest -f docker/Dockerfile --push .
|
||||
|
|
|
|||
Loading…
Reference in a new issue