-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI workflow for building and publishing Docker image
- Loading branch information
1 parent
0b11655
commit f80d345
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
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 |