Skip to content

Commit

Permalink
test2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarhan943 committed Oct 4, 2024
1 parent 55148f7 commit c87a7e9
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions .github/workflows/push-registrar-image.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
name: Build and Push Registrar Image
name: Build and Push Docker Images 101

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

schedule:
- cron: "0 4 * * 1-5" # UTC Time
pull_request:
branches:
- '**' # Trigger workflow on commits to any branch in a PR

jobs:
build-and-push-image:
build-and-push-docker-push:
runs-on: ubuntu-latest

steps:
- name: Get tag name
id: get-tag-name
uses: actions/github-script@v5
- name: Checkout code
uses: actions/checkout@v3
with:
script: |
const tagName = "${{ github.event.inputs.branch }}" || 'latest';
console.log('Will use tag: ' + tagName);
return tagName;
result-encoding: string
ref: ${{ github.event.inputs.branch || github.head_ref }}

- 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
fi
# 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 @@ -39,20 +46,7 @@ jobs:
- name: Build and push Dev Docker image
uses: docker/build-push-action@v6
with:
file: ./dockerfiles/registrar.Dockerfile
file: ./dockerfiles/course-discovery.Dockerfile
push: true
target: dev
tags: edxops/registrar-dev:${{ steps.get-tag-name.outputs.result }}

- name: Send failure notification
if: failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: email-smtp.us-east-1.amazonaws.com
server_port: 465
username: ${{secrets.edx_smtp_username}}
password: ${{secrets.edx_smtp_password}}
subject: Push Image to docker.io/edxops failed in registrar
to: team-cosmonauts@edx.org
from: github-actions <github-actions@edx.org>
body: Push Image to docker.io/edxops for registrar failed! For details see "github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
tags: farhan943/practise:${{ env.TAG }}

0 comments on commit c87a7e9

Please sign in to comment.