Sync your Spotify to Slack status
Tags: actionshackathon21
Published: 2021-11-28 15:06:45

This is a an open-source project that serves as both [website ](https://spotmystatus.giomo.de/)as well as a backend for Slack app that synchronizes Spotify song to your Slack status.


### My Workflow
GitHub workflow [master.yml](https://github.com/giorgimode/SpotMyStatus/blob/master/.github/workflows/master.yml):
1. Workflow sets up appropriate environment using [actions/checkout](https://github.com/marketplace/actions/checkout) and [actions/setup-java](https://github.com/marketplace/actions/setup-java-jdk).
2. After that the gradle packages are cached via [actions/cache@v2](https://github.com/marketplace/actions/cache) 
3. Gradle properties file is read via [christian-draeger/read-properties](https://github.com/marketplace/actions/read-properties), so that final deployment file can inherit proper semantic version 
4. Once the build is finished and the final zip file is generated, artifact is deployed to AWS beanstalk via [einaregilsson/beanstalk-deploy](https://github.com/marketplace/actions/beanstalk-deploy). AWS credentials are passed via Github secrets

As a result, workflow deploys a new version of the application to AWS beanstalk as soon as a change is detected on master branch.

```yaml
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 11
        uses: actions/setup-java@v1
        with:
          java-version: 11.0.4
      - name: Cache Gradle packages
        uses: actions/cache@v2
        with:
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
          restore-keys: ${{ runner.os }}-gradle
      - name: Grant execute permission for gradlew
        run: chmod +x gradlew
      - name: Build with Gradle
        run: ./gradlew build
      - name: Read baseVersion from gradle.properties
        id: read_artifact_version
        uses: christian-draeger/read-properties@1.0.1
        with:
          path: './gradle.properties'
          property: 'baseVersion'

      - name: Generate deployment package
        run: zip -j spotmystatus.zip backend/build/libs/spotmystatus-${{ steps.read_artifact_version.outputs.value }}.jar backend/Procfile && cd backend && zip -r ../spotmystatus.zip .ebextensions .platform
      - name: Deploy to AWS Beanstalk
        uses: einaregilsson/beanstalk-deploy@v13
        with:
          aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          application_name: SpotMyStatus
          environment_name: spotmystatus-environment
          version_label: ${{ steps.read_artifact_version.outputs.value }}-${{ github.run_id }}-${{ github.run_number }}
          use_existing_version_if_available: false
          wait_for_environment_recovery: 180
          region: eu-central-1
          deployment_package: spotmystatus.zip
```

### Submission Category: 
Wacky Wildcards: automate build and deployment of an artifact to AWS Beanstalk

### Link to workflow yaml file 
[Workflow yaml file for master branch](https://github.com/giorgimode/SpotMyStatus/blob/master/.github/workflows/master.yml)

### Repository
{% github https://github.com/giorgimode/SpotMyStatus %}


### Additional Resources / Info
* Website that running on AWS beanstalk and is deployed via this workflow: https://spotmystatus.giomo.de/
* Slack app: https://slack.com/apps/A01EZN95XD5-spotmystatus?tab=more_info