Skip to content

Commit

Permalink
Merge pull request #99 from mesoform/feat/SEC-147/docker_build_push
Browse files Browse the repository at this point in the history
Feat/sec 147/docker build push
  • Loading branch information
danperezsan authored Jun 5, 2024
2 parents 7d2c937 + 238cca4 commit 20dd7ee
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
with:
context: .
push: true
tags: mesoform/postgres-ha:${{ env.BRANCH_NAME }}
tags: mesoform/postgres-ha:${{ env.BRANCH_NAME }}
31 changes: 31 additions & 0 deletions .github/workflows/build_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and Push Docker Image on Merged Pull Request

on:
pull_request:
types: [closed]

jobs:
build:
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' && startsWith(github.event.pull_request.head.ref, 'pg-v') }}

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: mesoform/postgres-ha:latest
35 changes: 35 additions & 0 deletions .github/workflows/build_prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Push Docker Image on Merged Pull Request

on:
pull_request:
types: [closed]

jobs:
build:
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'dev-') && startsWith(github.event.pull_request.base.ref, 'pg-v') }}

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract target branch name
id: extract_branch
run: echo "TARGET_BRANCH=${{ github.event.pull_request.base.ref }}" >> $GITHUB_ENV

- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: mesoform/postgres-ha:${{ env.TARGET_BRANCH }}
43 changes: 43 additions & 0 deletions .github/workflows/build_tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build and Push Release Docker Images

on:
push:
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract version parts
id: extract_version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
MAJOR_MINOR=$(echo $VERSION | awk -F '-' '{print $1}')
MAJOR=$(echo $MAJOR_MINOR | awk -F '.' '{print $1}')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAJOR_MINOR=$MAJOR_MINOR" >> $GITHUB_ENV
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
- name: Build and push Docker images
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
mesoform/postgres-ha:release-${{ env.VERSION }}
mesoform/postgres-ha:release-${{ env.MAJOR_MINOR }}
mesoform/postgres-ha:${{ env.MAJOR }}-latest

0 comments on commit 20dd7ee

Please sign in to comment.