Skip to content

Commit

Permalink
Create elastic-beanstalk-deploy.yml
Browse files Browse the repository at this point in the history
CatalinMo authored Jun 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 073c49a commit 3b48377
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/elastic-beanstalk-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy to Elastic Beanstalk

on:
workflow_dispatch:
inputs:
environment:
description: 'Select the environment'
required: true
default: 'dev'
type: choice
options:
- dev
- prod

jobs:
build:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 21
uses: actions/setup-java@v2
with:
java-version: 21
- name: Extract project name and version from gradle.properties
id: get_project_info
run: |
projectName=$(grep '^projectName=' gradle.properties | cut -d'=' -f2)
version=$(grep '^version=' gradle.properties | cut -d'=' -f2)
appName="${projectName}-${version}"
versionLabel="${version}-${GITHUB_SHA}"
echo "APP_NAME=$appName" >> $GITHUB_ENV
echo "VERSION_LABEL=$versionLabel" >> $GITHUB_ENV
- name: build with gradlew
run: ./gradlew clean build
- name: Upload JAR
uses: actions/upload-artifact@v2
with:
name: jar-artifact
path: simple-app/build/libs/${{ env.APP_NAME }}.jar

deploy:
needs: build
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Download JAR
uses: actions/download-artifact@v2
with:
name: jar-artifact
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v20
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: ${{ vars.AWS_APPLICATION_NAME }}
environment_name: ${{ vars.AWS_ENVIRONMENT_NAME }}
version_label: ${{ env.VERSION_LABEL }}
region: ${{ vars.AWS_REGION }}
deployment_package: ${{ env.APP_NAME }}.jar

0 comments on commit 3b48377

Please sign in to comment.