update docker file and action to update readme with new sha #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy Docker Image | |
permissions: | |
contents: write | |
packages: write | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract short SHA | |
id: sha | |
run: echo "::set-output name=short_sha::$(echo ${GITHUB_SHA} | cut -c 1-7)" | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: mlpierce22/tea:${{ steps.sha.outputs.short_sha }} | |
- name: Output Docker image name | |
run: | | |
echo "Docker image name: mlpierce22/tea:${{ steps.sha.outputs.short_sha }}" | |
- name: Update Readme with Docker image name | |
run: sed -i "s/mlpierce22\/tea:.*/mlpierce22\/tea:${{ steps.sha.outputs.short_sha }}/" README.md | |
- uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Updated Docker image to mlpierce22\/tea:${{ steps.sha.outputs.short_sha }} | |
branch: main | |
commit_user_name: GitHub Actions |