From 74ab1a574d6397d677a4c358c5ed4d54df1be0b1 Mon Sep 17 00:00:00 2001 From: "Seele.Clover" <37256067+seeleclover@users.noreply.github.com> Date: Mon, 19 Feb 2024 04:19:05 +0800 Subject: [PATCH] Create Docker CI --- .github/workflows/docker-image-ci.yml | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/docker-image-ci.yml diff --git a/.github/workflows/docker-image-ci.yml b/.github/workflows/docker-image-ci.yml new file mode 100644 index 0000000..27af0cd --- /dev/null +++ b/.github/workflows/docker-image-ci.yml @@ -0,0 +1,57 @@ +name: Docker Image CI + +on: + push: + tags: + - '*.*.*' + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + env: + IMAGE_NAME: mariadb-connect + + steps: + - name: Get Version Name + id: version + run: echo "value=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Docker Meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{major}}.{{minor}}.{{patch}} + type=semver,pattern={{major}} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Build and Push Image + uses: docker/build-push-action@v5 + with: + context: . + push: true + build-args: | + MARIADB_VERSION=${{ steps.version.outputs.value }} + tags: ${{ steps.meta.outputs.tags }} + + - name: Update repo description + uses: peter-evans/dockerhub-description@v4 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + repository: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.IMAGE_NAME }} + short-description: ${{ github.event.repository.description }} + + - name: Push Summary + run: echo "### Build MariaDB ${{ steps.version.outputs.value }} Successfully :rocket:" >> $GITHUB_STEP_SUMMARY