Skip to content

Commit

Permalink
spotify
Browse files Browse the repository at this point in the history
  • Loading branch information
johndeniel committed Jun 9, 2024
1 parent 9442072 commit d7b7a1f
Show file tree
Hide file tree
Showing 17 changed files with 2,070 additions and 645 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPOTIFY_CLIENT_ID=
SPOTIFY_CLIENT_SECRET=
SPOTIFY_PLAYLIST_ID=
67 changes: 67 additions & 0 deletions .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Docker Hub Deployment
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: pulling git repo
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Build and test code
run: |
cargo build --verbose
cargo test --verbose
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/spotify:build-v1.001
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

- name: Deploy container
env:
SPOTIFY_CLIENT_ID: ${{ secrets.SPOTIFY_CLIENT_ID }}
SPOTIFY_CLIENT_SECRET: ${{ secrets.SPOTIFY_CLIENT_SECRET }}
SPOTIFY_PLAYLIST_ID: ${{ secrets.SPOTIFY_PLAYLIST_ID }}
run: |
docker run -e SPOTIFY_CLIENT_ID=${SPOTIFY_CLIENT_ID} \
-e SPOTIFY_CLIENT_SECRET=${SPOTIFY_CLIENT_SECRET} \
-e SPOTIFY_PLAYLIST_ID=${SPOTIFY_PLAYLIST_ID} \
-p 7860:7860 ${{ secrets.DOCKER_HUB_USERNAME }}/spotify:build-v1.001
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/section_01/target
/target
.env
Loading

0 comments on commit d7b7a1f

Please sign in to comment.