2024-05-05 18:58:20 -05:00
|
|
|
name: Docker Build and Publish
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths:
|
2024-05-05 19:12:22 -05:00
|
|
|
- "**/Containerfile"
|
2024-05-05 18:58:20 -05:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build_and_publish:
|
|
|
|
name: Build and Publish Docker Image
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Get Dockerfile image name
|
|
|
|
id: get_image_name
|
|
|
|
run: |
|
2024-05-05 19:32:40 -05:00
|
|
|
IMAGE_NAME=$(grep -Po '(?<=name=")[^"]*' Containerfile)
|
2024-05-05 18:58:20 -05:00
|
|
|
echo "::set-output name=image_name::$IMAGE_NAME"
|
|
|
|
|
|
|
|
- name: Login to container registry
|
|
|
|
run: docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} scm.wyattjmiller.com
|
|
|
|
|
|
|
|
- name: Check for Dockerfile changes
|
|
|
|
id: dockerfile_changed
|
|
|
|
run: |
|
2024-05-05 19:32:40 -05:00
|
|
|
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^Containerfile$'; then
|
2024-05-05 18:58:20 -05:00
|
|
|
echo "::set-output name=changed::true"
|
|
|
|
else
|
|
|
|
echo "::set-output name=changed::false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Build and Publish Docker image
|
|
|
|
if: steps.dockerfile_changed.outputs.changed == 'true'
|
|
|
|
run: |
|
|
|
|
docker build -t scm.wyattjmiller.com/${{ steps.get_image_name.outputs.image_name }}:${{ github.sha }} .
|
|
|
|
docker push scm.wyattjmiller.com/${{ steps.get_image_name.outputs.image_name }}:${{ github.sha }}
|