Skip to content
Open
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
88 changes: 88 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: vProfile CI/CD Pipeline

on:
push:
branches: [ main ]
workflow_dispatch:

jobs:
test:
name: Test the Pipeline
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Print a message
run: echo "Pipeline is running!"

- name: List project files
run: ls -la

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'

- name: Verify Java is installed
run: java -version

- name: Build with Maven
run: mvn install -DskipTests

- name: Verify artifact was created
run: ls -la target/*.war

- name: Run tests
run: mvn test

deploy:
name: Deploy to Beanstalk
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'corretto'

- name: Build artifact
run: mvn install -DskipTests

- 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: ${{ secrets.AWS_REGION }}
- name: Upload artifact to S3
run: |
TIMESTAMP=$(date +%Y%m%d%H%M%S)
VERSION_LABEL=vprofile-$TIMESTAMP
aws s3 cp target/vprofile-v2.war \
s3://${{ secrets.S3_BUCKET }}/$VERSION_LABEL.war
echo "VERSION_LABEL=$VERSION_LABEL" >> $GITHUB_ENV

- name: Create Beanstalk application version
run: |
aws elasticbeanstalk create-application-version \
--application-name ${{ secrets.EB_APPLICATION_NAME }} \
--version-label ${{ env.VERSION_LABEL }} \
--source-bundle S3Bucket=${{ secrets.S3_BUCKET }},S3Key=${{ env.VERSION_LABEL }}.war

- name: Deploy to Beanstalk
run: |
aws elasticbeanstalk update-environment \
--application-name ${{ secrets.EB_APPLICATION_NAME }} \
--environment-name ${{ secrets.EB_ENVIRONMENT_NAME }} \
--version-label ${{ env.VERSION_LABEL }}

- name: Deployment complete
run: echo "Deployed ${{ env.VERSION_LABEL }} to Beanstalk!"