Skip to content

Commit

Permalink
Refactor CI workflow to include separate test and build steps, and up…
Browse files Browse the repository at this point in the history
…date Docker image naming and tagging
  • Loading branch information
danishjoseph committed Apr 22, 2024
1 parent 3de6dc4 commit 4859616
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ permissions:

jobs:
test:
name: Unit tests & Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -34,6 +35,7 @@ jobs:
run: yarn test --colors

build:
name: Build Docker image & save to artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -51,14 +53,6 @@ jobs:
with:
name: docker-image
path: stockdog-pr-${{ github.event.number }}.image.tar

- name: Download Docker image from artifact
uses: actions/download-artifact@v4
with:
name: docker-image

- name: Load Docker image
run: docker load < stockdog-pr-${{ github.event.number }}.image.tar

push:
needs: build
Expand All @@ -73,7 +67,9 @@ jobs:
name: docker-image

- name: Load Docker image
run: docker load < stockdog-pr-${{ github.event.number }}.image.tar
run: |
docker load < stockdog-pr-${{ github.event.number }}.image.tar
docker tag stockdog:pr-${{ github.event.number }} stockdog:alpha-${{ github.event.number }}
- name: Login to DockerHub
uses: docker/login-action@v3
Expand All @@ -82,12 +78,12 @@ jobs:
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Push Docker image
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:pr-${{ github.event.number }}
run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:alpha-${{ github.event.number }}

- name: Update image metadata
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:pr-${{ github.event.number }}
images: ${{ secrets.DOCKER_HUB_USERNAME }}/stockdog:alpha-${{ github.event.number }}
tags: |
type=sha
labels: |
Expand Down

0 comments on commit 4859616

Please sign in to comment.