My Workflow
Pull requests deserve to be celebrated 🎉! This workflow integrates with smart devices to celebrate when a pull request is created. This introduces some fun into the process & could help with team morale. It's especially nice when teams haven't seen each-other due to the pandemic. The celebration includes the following:
- Turn on 🟢 smart bulb.
- Play celebration music 🎵 on smart speaker.
- Wait 10 seconds to enjoy the music 🕺.
Send request to Raspberry Pi 🥧 to take a celebration photo:
a. Raspberry Pi takes the photo 📸.
b. Raspberry Pi uploads the photo to cloud storage.Post message with the celebration picture to the pull request 🎉🎉🎉.
Video Demo of Workflow in Action
Submission Category:
Interesting IoT
Yaml File or Link to Code
Workflow Yaml
name: PR Celebration
on:
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Turn office light on with green
uses: kriscfoster/tplink-action@v1.4
with:
email: ${{ secrets.TPLINK_EMAIL }}
password: ${{ secrets.TPLINK_PASSWORD }}
deviceType: "HS100"
deviceId: ${{ secrets.TPLINK_DEVICE_ID }}
operation: "powerOn"
- name: Play celebration song with Spotify
uses: fjogeleit/http-request-action@v1.8.1
with:
url: https://api.spotify.com/v1/me/player/play?device_id=${{ secrets.SPOTIFY_DEVICE_ID }}
method: PUT
contentType: application/json
data: "{\"context_uri\":\"${{ secrets.SPOTIFY_CONTEXT_URI }}\",\"offset\":{\"position\":0},\"position_ms\":0}"
bearerToken: ${{ secrets.SPOTIFY_PLAYER_API_TOKEN }}
- name: Enjoy song for 10 seconds
run: sleep 10s
shell: bash
- name: Take celebration picture
id: retrieve_celebration_picture
run: |
echo "::set-output name=id::$(curl -H Authorization:${{ secrets.AUTHORIZATION_TOKEN }} ${{ secrets.PI_ENDPOINT }} | jq .id | tr -d '"')"
- name: Post celebration picture
uses: octokit/request-action@v2.1.0
with:
route: POST /repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/issues/${{ github.event.number }}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.number }}
body: "Tests Passed, it's time to celebrate!:tada::tada::tada:<br />![image](https://drive.google.com/uc?export=view&id=${{ steps.retrieve_celebration_picture.outputs.id }})"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Link to Code
PR Celebration GitHub Workflow 🎉 🎉 🎉
This is an entry for the 2021 GitHub Actions Hackathon.
My Workflow
Pull requests deserve to be celebrated
-
Turn on
🟢 smart bulb. -
Play celebration music
🎵 on smart speaker. -
Wait 10 seconds to enjoy the music
🕺 . -
Send request to Raspberry Pi
🥧 to take a celebration photo.a. Raspberry Pi takes the photo
📸 .b. Raspberry Pi uploads the photo to cloud storage.
-
Post message with the celebration picture to the pull request
🎉 🎉 🎉 .
Video Demo
You can see a video demo of the GitHub workflow in action here.
Submission Category:
Interesting IoT
Yaml File or Link to Code
…How was this Made?
I already had some smart devices so decided to use whatever I already had for the workflow.
Turning on Green Light 🟢
I used a combination of a green bulb & a TP-Link smart plug for this. The TP-Link plug can be turned on/off using their API but I decided to wrap this functionality into an action that could be used by my workflow & utilized by other workflows in the future. I created this under tplink-action.
Playing Music on Smart Speaker 🎵
I used the spotify API directly for this component. Once authenticated, you can use the spotify API to play songs/playlists on a device associated with your account. I have a smart speaker that is connected to spotify so I just needed to make an API call to play celebration music on this speaker.
Taking & Uploading Photo with Raspberry Pi 🥧
This was probably the most complicated part of the project. I built & expose an API from my Raspberry Pi. The code for this API is here. When a request is made to an endpoint on this API, it takes a photo with a camera module on the Raspberry Pi & then uploads the photo to cloud storage. The API response contains the identifier of the photo in storage so the workflow knows how to use it.
Posting Photo as Comment on Pull Request 🎉
I use the octokit/request-action
action to post the photo from cloud storage to the pull request.
Top comments (2)
Awesome one, pal!
Dang Nice Man, wonderful idea!