Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

# name - optional
name: Java CI with Gradle

# Events (required)
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

workflow_dispatch:
inputs:
environment:
description: 'CI'
required: true
default: 'dev'
# push:
# branches:
# - master
# - sanchitavrm-patch-1
# pull_request:
# branches: [ master ]

# Include set of actions
jobs:
build-java:

runs-on: ubuntu-latest
environment: dev # this line enables access to the secrets

steps:
- uses: actions/checkout@v2
Expand All @@ -26,13 +36,19 @@ jobs:
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build
run: |
./gradlew build
ls build/libs/


# marketplace actions
- name: Build and Push Docker Image
uses: mr-smithers-excellent/docker-build-push@v4
with:
image: nanajanashia/demo-app
image: sanchitavrm/demo-app
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}



78 changes: 78 additions & 0 deletions .github/workflows/ci_ecr
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
# name - optional
name: Java CI with Gradle, Push to ECR
# Events (required)
on:
workflow_dispatch:
inputs:
environment:
description: 'CI'
required: true
default: 'dev'
env:
AWS_REGION: us-east-1 # Change to your region
ECR_REPOSITORY: dev/github-action # Change to your ECR repo name
IMAGE_TAG: latest # Can be dynamic (e.g., Git SHA or version)


push:
branches:
- master
- sanchitavrm-patch-1
# pull_request:
# branches: [ master ]

# Include set of actions
jobs:
build-java:

runs-on: ubuntu-latest
environment: dev # this line enables access to the secrets

steps:
- uses: actions/checkout@v2

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: |
./gradlew build
ls build/libs/


- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2


- name: Build Docker Image
run: |
docker build -t $ECR_REPOSITORY:$IMAGE_TAG .

- name: Tag Docker Image for ECR
run: |
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
IMAGE_URI=$ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REPOSITORY:$IMAGE_TAG $IMAGE_URI
echo "IMAGE_URI=$IMAGE_URI" >> $GITHUB_ENV

- name: Push Docker Image to ECR
run: |
docker push $IMAGE_URI



2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = 'java-app'
rootProject.name = 'my-app'