Skip to content

Commit

Permalink
Add CI workflow for building and publishing Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
danishjoseph committed Apr 21, 2024
1 parent 0b11655 commit f80d345
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Test Build and Publish Docker image

on:
push:
branches: [main]
jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up NodeJS
uses: actions/setup-node@v2
with:
node-version: 18

- name: Install dependencies
run: yarn install

- name: Run tests
run: yarn test

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Create .env file
run: echo "${{ secrets.ENV }}" | base64 -d > .env

- name: Build and tag Docker image
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:pr-${{ github.event.number }} .
- name: Push Docker image
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:pr-${{ github.event.number }}

- name: Update image metadata
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:pr-${{ github.event.number }}
tags: |
type=sha
labels: |
org.opencontainers.image.title=StockDog App
org.opencontainers.image.description=Stock market analysis app
org.opencontainers.image.url=https://github.com/${{github.repository}}
org.opencontainers.image.revision=${{github.sha}}
org.opencontainers.image.licenses=MIT

0 comments on commit f80d345

Please sign in to comment.