forked from edx/public-dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
461f56f
commit 29d0673
Showing
1 changed file
with
19 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
@@ -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() | ||
|
@@ -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 }}" |