chehcking slug action #47
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: | |
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 | |
- name: slug_action | |
- run: | | |
echo "Partial variables" | |
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART }}" | |
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART }}" | |
echo "Slug variables" | |
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}" | |
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" | |
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" | |
echo " ref : ${{ env.GITHUB_REF_SLUG }}" | |
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}" | |
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}" | |
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}" | |
echo "Slug URL variables" | |
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}" | |
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" | |
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" | |
echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}" | |
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}" | |
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}" | |
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}" | |
echo "Short SHA variables" | |
echo " sha : ${{ env.GITHUB_SHA_SHORT }}" | |
echo " pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" | |
uses: rlespinasse/github-slug-action@v4 | |
with: | |
gradle-version: 7.6 | |
- run: gradle assemble -Pversion=${{ github.ref_name }} | |
- 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 }}." |