diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml new file mode 100644 index 0000000..a0ee60a --- /dev/null +++ b/.github/workflows/build-publish.yml @@ -0,0 +1,45 @@ +name: Build and Publish + +on: + push: + branches: + - 'main' + paths: + - 'Dockerfile' + - '**.py' + - 'requirements.txt' + - '.github/workflows/build-publish.yml' + +jobs: + build_and_publish_docker_image: + runs-on: ubuntu-latest + env: + DOCKERHUB_REPO: 'theodore86/aws-route53' + steps: + - name: 'Checkout SCM' + uses: 'actions/checkout@v3.1.0' + + - name: 'Login to docker registry' + uses: 'docker/login-action@v2.0.0' + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + logout: true + + - name: 'Retrieve latest commit sha as image tag' + id: 'git_short_sha' + run: | + short_sha=$(git log -1 --format=%h) + echo "::set-output name=short_sha::$short_sha" + + - name: 'Build and push docker image' + uses: 'docker/build-push-action@v3.0.0' + with: + push: true + context: . + file: Dockerfile + no-cache: true + tags: | + ${{ env.DOCKERHUB_REPO }}:${{ steps.git_short_sha.outputs.short_sha }} + ${{ env.DOCKERHUB_REPO }}:latest +