Feature/add main.yml #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI CD | |
on: | |
push: | |
branches: main | |
pull_request: | |
branches: main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Java 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '11' | |
cache: 'gradle' | |
- name: Setup Gradle 7.6 | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-version: 7.6 | |
- run: gradle assemble | |
- name: upload the build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: apache-spark-framework-artifact | |
path: build/libs | |
retention-days: 1 | |
- name: Setup caches | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/build/libs | |
key: ${{ runner.os }}-build | |
restore-keys: | | |
${{ runner.os }}-build | |
test: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Java 11 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '11' | |
cache: 'gradle' | |
- name: Setup Gradle 7.6 | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-version: 7.6 | |
- name: Running Unit Tests | |
run: gradle check | |
# https://github.com/aws-actions/configure-aws-credentials | |
publish: | |
name: "publish: upload artifact to aws s3" | |
needs: test | |
runs-on: ubuntu-latest | |
# These permissions are needed to interact with GitHub's OIDC Token endpoint. | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Download a single artifact | |
# https://github.com/actions/download-artifact | |
uses: actions/download-artifact@v3 | |
id: download-artifact | |
with: | |
name: apache-spark-framework-artifact | |
path: build/libs | |
- name: Configure AWS credentials from Test account | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_DEV_GITHUB_ACTION_ROLE }} | |
aws-region: us-west-2 | |
- name: Copy files to the test website with the AWS CLI | |
run: | | |
ls -lrt ${{steps.download-artifact.outputs.download-path}} | |
aws s3 sync ${{steps.download-artifact.outputs.download-path}} ${{ vars.AWS_S3_PATH }} | |
aws s3 ls ${{ vars.AWS_S3_PATH }} | |
echo "🍏 This job's status is ${{ job.status }}." |