Skip to content

Commit

Permalink
Merge pull request #377 from n0th1ng-else/commit-status
Browse files Browse the repository at this point in the history
feat(ci): Show docker image tag in the commit status check
  • Loading branch information
n0th1ng-else authored Mar 24, 2024
2 parents a52655d + cb0b098 commit 72b084a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
secrets: inherit
with:
version: ${{ needs.prerelease.outputs.version }}
sha: ${{ github.sha }}
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ jobs:
uses: ./.github/workflows/docker.yml
secrets: inherit
with:
version: 0.0.0-${{ github.sha }}
version: 0.0.0-${{ github.event.pull_request.head.sha }}
sha: ${{ github.event.pull_request.head.sha }}
5 changes: 5 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
type: string
description: "Version tag"
required: true
sha:
type: string
default: "Commit sha"
required: true

jobs:
deploy:
Expand All @@ -15,6 +19,7 @@ jobs:
with:
docker-tag: latest
version: ${{ inputs.version }}
sha: ${{ inputs.sha }}

heroku:
runs-on: ubuntu-latest
Expand Down
34 changes: 31 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ on:
type: string
description: "Version tag"
required: true
sha:
type: string
default: "Commit sha"
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}"
run: echo "Picked the app version ${{ inputs.sha }}"

- name: Checkout
uses: actions/checkout@v4
Expand All @@ -36,7 +41,7 @@ jobs:
context: .
push: true
tags: |
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:${{ github.sha }}
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:${{ inputs.sha }}
build-args: APP_VERSION=${{ inputs.version }}

- name: Publish to Registry and extra tag
Expand All @@ -47,5 +52,28 @@ jobs:
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 }}
ghcr.io/${{ secrets.DOCKER_USERNAME }}/voice-to-text-bot/voice-to-speech-app:${{ inputs.sha }}
build-args: APP_VERSION=${{ inputs.version }}

- name: Add image reference
uses: actions/github-script@v7
env:
COMMIT_SHA: ${{ inputs.sha }}
with:
script: |
const container = 'voice-to-speech-app'
const sha = process.env.COMMIT_SHA
const { owner, repo } = context.issue;
const target_url = `https://github.com/${owner}/${repo}/pkgs/container/${encodeURIComponent(`${repo}/${container}`)}`
const description = `${container}:${sha}`;
const api = `/repos/${owner}/${repo}/statuses/${sha}`;
await github.request(`POST ${api}`, {
owner,
repo,
sha,
target_url,
state: 'success',
description,
context: 'Docker image'
});

0 comments on commit 72b084a

Please sign in to comment.