From 54d6177e7445b41b6043d40b3a093ba119920769 Mon Sep 17 00:00:00 2001 From: Muhammed Iqbal Date: Tue, 28 Feb 2023 16:09:33 +0400 Subject: [PATCH 1/2] workflow updates --- .github/workflows/build-and-push.yml | 43 ++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index b193c72..f60f526 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -1,10 +1,17 @@ name: Build and Push to Docker Hub on: + schedule: + - cron: '0 10 * * 0' push: - branches: [master, release/*] + branches: + - '**' tags: - - '*' + - 'v*.*.*' + pull_request: + +env: + DOCKER_IMAGE: diquzart/go-app jobs: build-and-push: @@ -14,6 +21,20 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.DOCKER_IMAGE }} + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -24,13 +45,11 @@ jobs: uses: docker/build-push-action@v2 with: context: ./Containerfile - args: | - --file ./Containerfile - --push - --tag diquzart/go-app:latest - --tag diquzart/go-app:${{ github.sha }} - --tag diquzart/go-app:${{ github.ref }} - --build-arg VERSION=${{ github.sha }} - secrets: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file + file: ./Containerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + build-args: | + VERSION=${{ github.sha }} + secrets: | + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file From d18aa57c6bd35c696a334464988d8668fb612369 Mon Sep 17 00:00:00 2001 From: Muhammed Iqbal Date: Tue, 28 Feb 2023 16:18:09 +0400 Subject: [PATCH 2/2] workflow updates --- .github/workflows/build-and-push.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index f60f526..2680e7f 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -41,15 +41,18 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push Docker image uses: docker/build-push-action@v2 with: - context: ./Containerfile + context: . file: ./Containerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} build-args: | - VERSION=${{ github.sha }} - secrets: | - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} \ No newline at end of file + VERSION=${{ github.sha }} \ No newline at end of file