From db0bf2133f85c9f15b5c692166a038da246fd356 Mon Sep 17 00:00:00 2001 From: Beeant Date: Sun, 5 Jun 2022 18:31:28 +0800 Subject: [PATCH] Update docker-image.yml --- .github/workflows/docker-image.yml | 39 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 223daac..1e5f412 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: [ main ] - tags: - - '*' + branches: [ "main" ] + pull_request: + branches: [ "main" ] jobs: @@ -13,18 +13,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Set version - id: version - run: echo ::set-output name=release_version::${GITHUB_REF#refs/*/} - - - name: Build Docker image - run: | - echo Building version ${{ steps.version.outputs.release_version }}... - docker build . --file Dockerfile --tag xbeeant/oo-unlimit:${{ steps.version.outputs.release_version }} - - - name: Push Docker image - run: | - echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }} - docker push xbeeant/oo-unlimit:${{ steps.version.outputs.release_version }} + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag xbeeant/oo-unlimit:$(date +%s) + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - name: Build image and push to Docker Hub and GitHub Container Registry + uses: docker/build-push-action@v2 + with: + # relative path to the place where source code with Dockerfile is located + context: ./ + # Note: tags has to be all lower-case + tags: | + xbeeant/devdocs:latest + # build on feature branches, push only on main branch + push: ${{ github.ref == 'refs/heads/main' }}