Skip to content

Commit

Permalink
Update GitHub release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Oct 3, 2023
1 parent 1667fee commit c568c37
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.
34 changes: 34 additions & 0 deletions .github/actions/docker-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Docker image

on:
workflow_call:
inputs:
version:
required: true
type: string
latest:
required: false
type: boolean
default: false

runs:
using: "composite"
steps:
- uses: actions/checkout@v3
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
ignore: DL3045,DL3007
- name: Build and push image
run: |
IMAGE_ID=$(echo "ghcr.io/${{ github.repository_owner }}/${{ vars.DOCKER_IMAGE_NAME }}" | tr '[A-Z]' '[a-z]')
echo "IMAGE_ID=$IMAGE_ID" >> "$GITHUB_OUTPUT"
docker build --tag $IMAGE_ID:${{ inputs.version }} --platform=linux/amd64 .
docker push $IMAGE_ID:${{ inputs.version }}
- name: Tag latest
if: inputs.latest
run: |
docker tag $IMAGE_ID:${{ inputs.version }} $IMAGE_ID:latest --platform=linux/amd64 .
docker push $IMAGE_ID:latest
38 changes: 0 additions & 38 deletions .github/workflows/_docker-build.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .github/workflows/cd-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ jobs:
deploy:
name: Deploy to AWS
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Get tag
id: version-tag
uses: ./.github/actions/get-version-tag
- name: Build
uses: ./.github/workflows/_docker-build.yml
uses: ./.github/actions/docker-build
with:
version: ${{ steps.version-tag.outputs.VERSION }}
- name: Install AWS CLI
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/cd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ jobs:
deploy:
name: Deploy to AWS
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Get tag
id: version-tag
uses: ./.github/actions/get-version-tag
- name: Build
uses: ./.github/workflows/_docker-build.yml
uses: ./.github/actions/docker-build
with:
version: ${{ steps.version-tag.outputs.VERSION }} # (latest)
- name: Install AWS CLI
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ jobs:
build:
name: Build and deploy to AWS
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Get tag
id: version-tag
uses: ./.github/actions/get-version-tag
- name: Build
uses: ./.github/workflows/_docker-build.yml
uses: ./.github/actions/docker-build
with:
version: ${{ steps.version-tag.outputs.VERSION }}
latest: true
Expand Down

0 comments on commit c568c37

Please sign in to comment.