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:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: synology-runner
|
runs-on: synology-runner
|
||||||
|
timeout-minutes: 30
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: |
|
run: |
|
||||||
git clone https://git.khoavo.myds.me/vndangkhoa/monochrome.git /workspace/monochrome
|
if [ -d "/workspace/monochrome" ]; then
|
||||||
cd /workspace/monochrome
|
rm -rf /workspace/monochrome
|
||||||
git checkout $GITHUB_SHA
|
fi
|
||||||
|
git clone --depth 1 https://git.khoavo.myds.me/vndangkhoa/monochrome.git /workspace/monochrome
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- 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
|
- name: Login to Forgejo Container Registry
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -30,8 +33,6 @@ jobs:
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
run: |
|
run: |
|
||||||
cd /workspace/monochrome
|
cd /workspace/monochrome
|
||||||
TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$(echo $GITHUB_SHA | cut -c1-8)"
|
COMMIT_SHA=$(git rev-parse HEAD)
|
||||||
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
|
TAG="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${COMMIT_SHA:0:8}"
|
||||||
TAG="$TAG ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:latest"
|
docker buildx build --platform linux/amd64 -t $TAG -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:latest -f docker/Dockerfile --push .
|
||||||
fi
|
|
||||||
docker buildx build --platform linux/amd64 -t $TAG -f docker/Dockerfile --push .
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue