From 395f029da66c19cae8ff83da9c09546694517745 Mon Sep 17 00:00:00 2001 From: nihaldivyam Date: Fri, 19 Jul 2024 12:59:49 +0530 Subject: [PATCH] build --- .github/workflows/docker-build.yaml | 54 +++++++++++++++++++ .github/workflows/postgres-logical-backup.yml | 35 ++++++------ 2 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/docker-build.yaml diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..8def555 --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,54 @@ +name: Docker Image CI + +on: + push: + branches: [ "v1.0.4" ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3.5.2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} # github username or org + password: ${{ secrets.GITHUB_TOKEN }} # github actions builtin token. repo has to have pkg access. + + - name: Prepare + id: prep + run: | + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v4.0.0 + with: + context: . + file: ./postgres-logical-backup/Dockerfile + platforms: linux/amd64 + pull: true # Pull new version of base image, always; avoid bit-rot + push: true + labels: | + org.opencontainers.image.title=${{ github.repository }} + org.opencontainers.image.description=${{ github.event.repository.description }} + org.opencontainers.image.url=${{ github.event.repository.html_url }} + org.opencontainers.image.source=${{ github.event.repository.clone_url }} + org.opencontainers.image.created=${{ steps.prep.outputs.created }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} + cache-from: type=gha # all-automatic Github Actions caching + cache-to: type=gha,mode=max + build-args: | + tags: ghcr.io/obmondo/postgres-logical-backup:latest \ No newline at end of file diff --git a/.github/workflows/postgres-logical-backup.yml b/.github/workflows/postgres-logical-backup.yml index 146e165..2e9b6a4 100644 --- a/.github/workflows/postgres-logical-backup.yml +++ b/.github/workflows/postgres-logical-backup.yml @@ -2,8 +2,8 @@ name: Build Logical backup on: push: - branches: [ "v1.0.4" ] - paths: 'postgres-logical-backup/**' + branches: [ "*" ] + paths: 'logical-backup/**' tags: [ "v*" ] jobs: @@ -17,17 +17,17 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - # - name: Generate container metadata - # id: meta - # uses: docker/metadata-action@v3 - # with: - # images: ghcr.io/obmondo/logical-backup - # tags: | - # type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }} - # type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} - # type=ref,event=tag - # flavor: | - # latest=false + - name: Generate container metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ghcr.io/obmondo/logical-backup + tags: | + type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }} + type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} + type=ref,event=tag + flavor: | + latest=false - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: @@ -39,9 +39,8 @@ jobs: id: docker_build uses: docker/build-push-action@v2 with: - file: "./postgres-logical-backup/Dockerfile" + file: "./logical-backup/Dockerfile" context: . - tags: ghcr.io/obmondo/postgres-logical-backup:latest - # labels: ${{ steps.meta.outputs.labels }} - # push: true - # tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file