From 224b6f499eaf05a50eae60ccc6582893babb52ae Mon Sep 17 00:00:00 2001 From: ethereal Date: Wed, 11 Jun 2025 16:15:37 +0800 Subject: [PATCH 1/3] feat(vermeer): add publish Docker image of vermeer --- .../publish_latest_vermeer_image.yml | 72 +++++++++++++++++++ .../publish_release_vermeer_image.yml | 49 +++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 .github/workflows/publish_latest_vermeer_image.yml create mode 100644 .github/workflows/publish_release_vermeer_image.yml diff --git a/.github/workflows/publish_latest_vermeer_image.yml b/.github/workflows/publish_latest_vermeer_image.yml new file mode 100644 index 0000000..2db11c3 --- /dev/null +++ b/.github/workflows/publish_latest_vermeer_image.yml @@ -0,0 +1,72 @@ +name: "Publish Vermeer Image(latest)" + +on: + schedule: + - cron: '0 23 * * *' + workflow_dispatch: + +jobs: + build_latest: + runs-on: ubuntu-latest + env: + REPOSITORY_URL: apache/incubator-hugegraph-computer + BRANCH: master + IMAGE_URL: hugegraph/vermeer:latest + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + OWNER: hugegraph + REPO: actions + LAST_VERMEER_HASH: ${{vars.LAST_VERMEER_HASH}} + + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Checkout latest + uses: actions/checkout@v4 + with: + repository: ${{ env.REPOSITORY_URL }} + ref: ${{ env.BRANCH }} + fetch-depth: 2 + + - name: Get current commit-hash + run: | + current_commit_hash=$(git rev-parse HEAD) + echo "CURRENT_COMMIT_HASH=$current_commit_hash" >> $GITHUB_ENV + + - name: Check if an update is needed + run: | + need_update='false' + if [[ "$CURRENT_COMMIT_HASH" != "$LAST_VERMEER_HASH" ]]; then + need_update='true' + fi + echo "NEED_UPDATE=$need_update" >> $GITHUB_ENV + # TODO: replace the `if` statements with a graceful exit once GitHub Actions supports it. + # See https://github.com/actions/runner/issues/662 for more details. + + - name: Build X86 & ARM And Push All + uses: docker/build-push-action@v5 + if: ${{ env.NEED_UPDATE == 'true' }} + with: + context: ./vermeer + file: ./vermeer/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: ${{ env.IMAGE_URL }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Update last commit-hash + if: ${{ env.NEED_UPDATE == 'true' }} + run: | + curl -L -X PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + https://api.github.com/repos/$OWNER/$REPO/actions/variables/LAST_VERMEER_HASH \ + -d '{"name":"LAST_VERMEER_HASH","value":"'"$CURRENT_COMMIT_HASH"'"}' diff --git a/.github/workflows/publish_release_vermeer_image.yml b/.github/workflows/publish_release_vermeer_image.yml new file mode 100644 index 0000000..dae688f --- /dev/null +++ b/.github/workflows/publish_release_vermeer_image.yml @@ -0,0 +1,49 @@ +name: "Publish Vermeer Image(release)" + +on: + workflow_dispatch: + inputs: + branch: + required: true + default: '' + description: 'The branch name should be like *-x.x.x, for example release-1.0.0' + +jobs: + build_latest: + runs-on: ubuntu-latest + env: + REPOSITORY_URL: apache/incubator-hugegraph-computer + BRANCH: ${{inputs.branch}} + + steps: + - name: Set image_url + run: | + image_url=apache/incubator-hugegraph-computer:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') + echo $image_url && echo "IMAGE_URL=$image_url" >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Checkout latest + uses: actions/checkout@v4 + with: + repository: ${{ env.REPOSITORY_URL }} + ref: ${{ env.BRANCH }} + fetch-depth: 2 + + - name: Build X86 & ARM And Push All + uses: docker/build-push-action@v5 + with: + context: ./vermeer + file: ./vermeer/Dockerfile + platforms: linux/amd64,linux/arm64 + tags: ${{ env.IMAGE_URL }} + push: true + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file From cdfae9b4ef3841d825a55dfb9ccae05cc8e1ede6 Mon Sep 17 00:00:00 2001 From: Ethereal-O <91931223+Ethereal-O@users.noreply.github.com> Date: Thu, 12 Jun 2025 12:10:55 +0800 Subject: [PATCH 2/3] add version check Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/publish_release_vermeer_image.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish_release_vermeer_image.yml b/.github/workflows/publish_release_vermeer_image.yml index dae688f..8144649 100644 --- a/.github/workflows/publish_release_vermeer_image.yml +++ b/.github/workflows/publish_release_vermeer_image.yml @@ -18,7 +18,12 @@ jobs: steps: - name: Set image_url run: | - image_url=apache/incubator-hugegraph-computer:$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') + version=$(echo "${{ inputs.branch }}" | grep -oP '(\d+\.\d+\.\d+)') + if [ -z "$version" ]; then + echo "Error: Branch name does not contain a valid version number (x.x.x)." >&2 + exit 1 + fi + image_url=apache/incubator-hugegraph-computer:$version echo $image_url && echo "IMAGE_URL=$image_url" >> $GITHUB_ENV - name: Set up Docker Buildx From ba3808117964af11c6459215e76d8f5d2c5a9629 Mon Sep 17 00:00:00 2001 From: ethereal Date: Thu, 12 Jun 2025 12:17:35 +0800 Subject: [PATCH 3/3] fix: image name --- .github/workflows/publish_release_vermeer_image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish_release_vermeer_image.yml b/.github/workflows/publish_release_vermeer_image.yml index 8144649..e6cef28 100644 --- a/.github/workflows/publish_release_vermeer_image.yml +++ b/.github/workflows/publish_release_vermeer_image.yml @@ -23,7 +23,7 @@ jobs: echo "Error: Branch name does not contain a valid version number (x.x.x)." >&2 exit 1 fi - image_url=apache/incubator-hugegraph-computer:$version + image_url=apache/vermeer:$version echo $image_url && echo "IMAGE_URL=$image_url" >> $GITHUB_ENV - name: Set up Docker Buildx @@ -51,4 +51,4 @@ jobs: tags: ${{ env.IMAGE_URL }} push: true cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max