Skip to content

Commit

Permalink
fix(ci): Build docker on PR level
Browse files Browse the repository at this point in the history
  • Loading branch information
n0th1ng-else committed Jan 20, 2024
1 parent 8799453 commit 66e1b2c
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 30 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ jobs:
scan:
uses: ./.github/workflows/scan.yml
secrets: inherit

deploy:
# needs: [scan]
uses: ./.github/workflows/docker.yml
secrets: inherit
with:
version: 0.0.0-${{ github.sha }}
36 changes: 6 additions & 30 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,12 @@ on:
required: true

jobs:
docker:
runs-on: ubuntu-latest
name: Push docker image
timeout-minutes: 5
steps:
- name: App version
run: echo "Picked the app version ${GITHUB_SHA}"

- name: Checkout
uses: actions/checkout@v3

- name: Install NodeJS and NPM modules
uses: ./.github/actions/npm

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Publish to Registry
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:latest
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:${{ github.sha }}
build-args: APP_VERSION=${{ inputs.version }}
deploy:
uses: ./.github/workflows/docker.yml
secrets: inherit
with:
docker-tag: latest
version: ${{ inputs.version }}

heroku:
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build docker image

on:
workflow_call:
inputs:
docker-tag:
type: string
description: "Extra docker tag"
version:
type: string
description: "Version tag"
required: true
jobs:
docker:
runs-on: ubuntu-latest
name: Push docker image
timeout-minutes: 5
steps:
- name: App version
run: echo "Picked the app version ${GITHUB_SHA}"

- name: Checkout
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Publish to Registry
if: inputs.docker-tag == ''
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:${{ github.sha }}
build-args: APP_VERSION=${{ inputs.version }}

- name: Publish to Registry and extra tag
if: inputs.docker-tag != ''
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:${{ inputs.docker-tag }}
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:${{ github.sha }}
build-args: APP_VERSION=${{ inputs.version }}

0 comments on commit 66e1b2c

Please sign in to comment.