From 0cb33081f154a797f9e12e42515be8c1fc4d94e5 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Wed, 7 Aug 2024 12:16:51 +0800 Subject: [PATCH 1/7] add MYSQL_HOST to README list of environment variables --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 13e4c79..ac3b8e8 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Service to backup and/or restore mysql databases to/from S3 and optionally to B2 `DB_NAMES` list of the database names +`MYSQL_HOST` hostname of the database server + `MYSQL_USER` user that accesses the database `MYSQL_PASSWORD` password for the `MYSQL_USER` From 304eec75035ad22343733ee49462a40304fc8b8e Mon Sep 17 00:00:00 2001 From: Praveen Date: Fri, 4 Oct 2024 13:10:15 +0530 Subject: [PATCH 2/7] Updated GitHub Actions workflow to push Docker image to GHCR with latest tag on main branch --- .github/workflows/build-and-publish.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 4237f6f..f64362a 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -2,33 +2,36 @@ name: Build and Publish on: push: + branches: + - main jobs: build-and-publish: - name: Build and Publish + name: Build and Publish to GHCR runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - - name: Log in to Docker Hub + - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: - images: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} + images: ghcr.io/${{ github.repository }} tags: | type=ref,event=branch type=ref,event=tag - # set latest tag for master branch - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + # set latest tag for main branch + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} - - name: Build and push Docker image + - name: Build and push Docker image to GHCR uses: docker/build-push-action@v5 with: context: . From 24e4a54e73a5c7d6af95b5d549255522ac04f57f Mon Sep 17 00:00:00 2001 From: Praveen Date: Fri, 4 Oct 2024 13:19:07 +0530 Subject: [PATCH 3/7] GitHub Actions workflow to push Docker image to both DockerHUB and GHCR with latest tag on main branch --- .github/workflows/build-and-publish.yml | 28 ++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index f64362a..27a6278 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -7,12 +7,21 @@ on: jobs: build-and-publish: - name: Build and Publish to GHCR + name: Build and Publish to DockerHub and GHCR runs-on: ubuntu-latest steps: + # Checkout the code - name: Checkout code uses: actions/checkout@v4 + # Log in to Docker Hub + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Log in to GitHub Container Registry (GHCR) - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: @@ -20,21 +29,34 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # Extract metadata (tags, labels) for Docker images - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository }} + images: | + ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} # For DockerHub + ghcr.io/${{ github.repository }} # For GHCR tags: | type=ref,event=branch type=ref,event=tag # set latest tag for main branch type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} - - name: Build and push Docker image to GHCR + # Build and push Docker image to Docker Hub + - name: Build and push Docker image to Docker Hub uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + + # Build and push Docker image to GHCR + - name: Build and push Docker image to GHCR + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From ac8446a0b16a06c0d578fa54553557fb77ff3f97 Mon Sep 17 00:00:00 2001 From: Praveen Date: Fri, 4 Oct 2024 13:23:59 +0530 Subject: [PATCH 4/7] Testing in the Develop branch with GitHub Actions workflow to push Docker image to both DockerHUB and GHCR with latest tag on main branch --- .github/workflows/build-and-publish.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 27a6278..c8daa24 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -1,13 +1,13 @@ -name: Build and Publish +name: Build and Publish (Develop) on: push: branches: - - main + - develop jobs: build-and-publish: - name: Build and Publish to DockerHub and GHCR + name: Build and Publish to DockerHub and GHCR (Develop) runs-on: ubuntu-latest steps: # Checkout the code @@ -39,9 +39,8 @@ jobs: ghcr.io/${{ github.repository }} # For GHCR tags: | type=ref,event=branch - type=ref,event=tag - # set latest tag for main branch - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + # set test tag for develop branch + type=raw,value=test,enable=${{ github.ref == 'refs/heads/develop' }} # Build and push Docker image to Docker Hub - name: Build and push Docker image to Docker Hub From cc31a56efe009025ccb8f4fad99f701cfca004a7 Mon Sep 17 00:00:00 2001 From: Praveen Date: Fri, 4 Oct 2024 13:31:39 +0530 Subject: [PATCH 5/7] Updated the tags --- .github/workflows/build-and-publish.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index c8daa24..4fe83ce 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -38,9 +38,8 @@ jobs: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} # For DockerHub ghcr.io/${{ github.repository }} # For GHCR tags: | - type=ref,event=branch - # set test tag for develop branch - type=raw,value=test,enable=${{ github.ref == 'refs/heads/develop' }} + type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/develop' }} # Build and push Docker image to Docker Hub - name: Build and push Docker image to Docker Hub @@ -48,8 +47,8 @@ jobs: with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}:latest # Build and push Docker image to GHCR - name: Build and push Docker image to GHCR @@ -57,5 +56,5 @@ jobs: with: context: . push: true - tags: ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: | + ghcr.io/${{ github.repository }}:develop From cc84821354ae0099798779ed182feaab29863d48 Mon Sep 17 00:00:00 2001 From: Praveen Date: Fri, 4 Oct 2024 13:39:48 +0530 Subject: [PATCH 6/7] Updated for the main branch --- .github/workflows/build-and-publish.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 4fe83ce..8c37dcb 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -1,13 +1,13 @@ -name: Build and Publish (Develop) +name: Build and Publish on: push: branches: - - develop + - main jobs: build-and-publish: - name: Build and Publish to DockerHub and GHCR (Develop) + name: Build and Publish to DockerHub and GHCR runs-on: ubuntu-latest steps: # Checkout the code @@ -38,8 +38,8 @@ jobs: ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} # For DockerHub ghcr.io/${{ github.repository }} # For GHCR tags: | - type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }} - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/develop' }} + type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} # Build and push Docker image to Docker Hub - name: Build and push Docker image to Docker Hub @@ -57,4 +57,4 @@ jobs: context: . push: true tags: | - ghcr.io/${{ github.repository }}:develop + ghcr.io/${{ github.repository }}:main From 782944eedafd2e36ae7781a084787ec53bd1456d Mon Sep 17 00:00:00 2001 From: Praveen Date: Tue, 8 Oct 2024 11:56:03 +0530 Subject: [PATCH 7/7] updated the tags updated the tags with versions --- .github/workflows/build-and-publish.yml | 40 ++++++++++--------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml index 8c37dcb..31841cc 100644 --- a/.github/workflows/build-and-publish.yml +++ b/.github/workflows/build-and-publish.yml @@ -2,26 +2,23 @@ name: Build and Publish on: push: - branches: - - main + branches: [ 'main' ] # Trigger on push to 'main' + tags: [ '[0-9]+.[0-9]+.[0-9]+' ] # Trigger on version tags like '0.1.0' jobs: build-and-publish: - name: Build and Publish to DockerHub and GHCR + name: Build and Publish Docker image runs-on: ubuntu-latest steps: - # Checkout the code - name: Checkout code uses: actions/checkout@v4 - # Log in to Docker Hub - name: Log in to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - # Log in to GitHub Container Registry (GHCR) - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: @@ -29,32 +26,27 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # Extract metadata (tags, labels) for Docker images - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: | - ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} # For DockerHub - ghcr.io/${{ github.repository }} # For GHCR + ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }} + ghcr.io/${{ github.repository }} tags: | - type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }} - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=ref,event=branch # Tag with branch name + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + # labels: | + # org.opencontainers.image.source=${{ github.repository }} + # org.opencontainers.image.revision=${{ github.sha }} + # org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} - # Build and push Docker image to Docker Hub - - name: Build and push Docker image to Docker Hub + - name: Build and push Docker image to DockerHub and GHCR uses: docker/build-push-action@v5 with: context: . push: true - tags: | - ${{ vars.DOCKER_ORG }}/${{ github.event.repository.name }}:latest - - # Build and push Docker image to GHCR - - name: Build and push Docker image to GHCR - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: | - ghcr.io/${{ github.repository }}:main + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}