Merge pull request #22 from PartTimeLegend/renovate/terraform-docs-gh… #22
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 Publish Docker Image | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
permissions: write-all | |
env: | |
BUILD_DATE: ${{ github.event.head_commit.timestamp }} | |
IMAGE_NAME: hammy-mchamilton | |
REPO_OWNER: hamhangout | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 # Check out your repository's code | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate build number tag | |
id: generate_tag | |
run: echo ::set-output name=tag::${GITHUB_RUN_NUMBER} | |
- name: Build the Docker image | |
run: docker build --file Dockerfile --tag ghcr.io/${{ env.REPO_OWNER }}/${{ env.IMAGE_NAME }}:${{ steps.generate_tag.outputs.tag }} --tag ghcr.io/${{ env.REPO_OWNER }}/${{ env.IMAGE_NAME }}:latest --build-arg BUILD_DATE=${BUILD_DATE} . | |
- name: Push the Docker image to GitHub Container Registry | |
run: docker push ghcr.io/${{ env.REPO_OWNER }}/${{ env.IMAGE_NAME }}:${{ steps.generate_tag.outputs.tag }} && docker push ghcr.io/${{ env.REPO_OWNER }}/${{ env.IMAGE_NAME }}:latest |