From ae7dd5a20a6256c7d571a8a16d54d94dded1ea41 Mon Sep 17 00:00:00 2001 From: Your Name <> Date: Sun, 19 May 2024 22:41:22 +0800 Subject: [PATCH] ci --- .github/workflows/image-build.yml | 26 ++++++++++++++++++++++++++ build.sh | 12 +++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/image-build.yml diff --git a/.github/workflows/image-build.yml b/.github/workflows/image-build.yml new file mode 100644 index 0000000..ea5b67d --- /dev/null +++ b/.github/workflows/image-build.yml @@ -0,0 +1,26 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + run: ./build.sh diff --git a/build.sh b/build.sh index a207dde..3483142 100755 --- a/build.sh +++ b/build.sh @@ -2,10 +2,16 @@ USER=zerotier REPO=ZeroTierOne +DOCKER_IMAGE="xubiaolin/zerotier-planet" + latest_tag=$(curl -s "https://api.github.com/repos/$USER/$REPO/tags" | jq -r '.[].name' | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -n 1) +latest_docker_tag=$(curl -s "https://hub.docker.com/v2/repositories/${DOCKER_IMAGE}/tags/" | jq -r '.results[].name' | grep -E "^[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -n 1) + +# if [ "$latest_tag" == "$latest_docker_tag" ]; then +# echo "No new version found" +# exit 0 +# fi echo "Latest tag for $USER/$REPO matching latest is: $latest_tag" - -docker build --build-arg TAG="$latest_tag" -t "xubiaolin/zerotier-planet:$latest_tag" . -docker tag "xubiaolin/zerotier-planet:$latest_tag" "xubiaolin/zerotier-planet:latest" +docker buildx build --platform linux/arm64,linux/amd64 -t myimage:latest --push . \ No newline at end of file