# This workflow will build a Java project with Maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven name: Java CI with Maven on: push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up JDK 1.8 uses: actions/setup-java@v1 with: java-version: 1.8 - name: Build with Maven run: mvn -B package --file pom.xml - name: upoad artifacts uses: actions/upload-artifact@master with: name: Package path: /home/runner/work/hello-world-war/hello-world-war/target/hello-world-war-1.0.0.war test: needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/download-artifact@master with: name: Package path: staging - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 - name: Copy files to S3 with the AWS CLI run: | aws s3 sync /home/runner/work/hello-world-war/hello-world-war/staging s3://sam-githubaction - name: Deploy to AWS CloudFormation uses: aws-actions/aws-cloudformation-github-deploy@v1 with: name: MyStack # This template installs Tomcat and deploys the war file built in the above step template: ec2instance_linux_master_template.yaml capabilities: CAPABILITY_NAMED_IAM