Skip to content

Commit

Permalink
Build Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Dec 29, 2023
1 parent 69edd6f commit e262d94
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/actions/docker-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Docker image

inputs:
version:
required: true
type: string
latest:
required: false
type: boolean
default: false
github-token:
required: true
type: string
docker-image-name:
required: true
type: string

runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- name: Log in to registry
run: echo "${{ inputs.github-token }}" | docker login ghcr.io -u $ --password-stdin
shell: bash
- uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
ignore: DL3045,DL3007
- name: Build and push image
run: |
IMAGE_ID=$(echo "ghcr.io/${{ github.repository_owner }}/${{ inputs.docker-image-name }}" | tr '[A-Z]' '[a-z]')
echo "IMAGE_ID=$IMAGE_ID" >> "$GITHUB_OUTPUT"
echo $IMAGE_ID
docker build --tag $IMAGE_ID:${{ inputs.version }} --platform=linux/amd64 --no-cache .
docker push $IMAGE_ID:${{ inputs.version }}
shell: bash
- name: Tag latest
if: inputs.latest
run: |
IMAGE_ID=$(echo "ghcr.io/${{ github.repository_owner }}/${{ inputs.docker-image-name }}" | tr '[A-Z]' '[a-z]')
echo $IMAGE_ID
docker tag $IMAGE_ID:${{ inputs.version }} $IMAGE_ID:latest
docker push $IMAGE_ID:latest
shell: bash
15 changes: 15 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ on:
- proof-of-concept

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get tag
id: version-tag
uses: ./.github/actions/get-version-tag
- name: Build Docker image
uses: ./.github/actions/docker-build
with:
version: ${{ steps.version-tag.outputs.version-tag }}
latest: true
github-token: ${{ secrets.GITHUB_TOKEN }}
docker-image-name: ${{ vars.DOCKER_IMAGE_NAME }}

deploy:
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit e262d94

Please sign in to comment.