Skip to content

Commit

Permalink
test2
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarhan943 committed Oct 3, 2024
1 parent 461f56f commit 29d0673
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions .github/workflows/push-registrar-image.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Build and Push Docker Images

on:
workflow_dispatch:
inputs:
branch:
description: "Target branch from which the source Dockerfile will be sourced"
required: true

pull_request:
branches:
- '**' # Trigger workflow on commits to any branch in a PR
Expand All @@ -12,10 +18,17 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch || github.head_ref }}

- name: Get commit SHA for tagging
id: get-commit-sha
run: echo "COMMIT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV
- name: Get tag for the image
id: get-tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "TAG=${{ github.event.inputs.branch }}" >> $GITHUB_ENV
else
echo "TAG=${GITHUB_SHA::8}" >> $GITHUB_ENV
# This sets the tag to the branch name for manual trigger and commit SHA for PR

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -35,7 +48,7 @@ jobs:
file: ./dockerfiles/registrar.Dockerfile
push: true
target: dev
tags: farhan943/practise:${{ env.COMMIT_SHA }} # Use commit SHA as tag
tags: farhan943/practise:${{ env.TAG }}

- name: Send failure notification
if: failure()
Expand All @@ -45,7 +58,7 @@ jobs:
server_port: 465
username: ${{ secrets.edx_smtp_username }}
password: ${{ secrets.edx_smtp_password }}
subject: Docker Image push failed for commit ${{ env.COMMIT_SHA }}
subject: Docker image push failed for ${{ env.TAG }}
to: [email protected]
from: github-actions <[email protected]>
body: Docker image push failed for PR commit! For details see "github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
body: Docker image push failed for tag ${{ env.TAG }}! For details see "github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"

0 comments on commit 29d0673

Please sign in to comment.