Skip to content

Merge pull request #5 from EzioDEVio/develop #3

Merge pull request #5 from EzioDEVio/develop

Merge pull request #5 from EzioDEVio/develop #3

Workflow file for this run

name: Build and Push Docker image to Github Container Registry
on:
push:
branches:
- main
concurrency:
group: ghcr-build-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.set_output.outputs.image_tag }} # This will set the output for the job
steps:
- name: Check out the code
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set lowercase repository owner and set image tag
id: set_output
run: |
REPO_OWNER=$(echo ${{ github.repository_owner }} | awk '{print tolower($0)}')
IMAGE_TAG="v1.2.1"
echo "REPO_OWNER=$REPO_OWNER" >> $GITHUB_ENV
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
echo "::set-output name=image_tag::$IMAGE_TAG" # This sets the output for image tag
- name: Build Docker image with specific tag
run: |
echo "Building Image: ghcr.io/${{ env.REPO_OWNER }}/ghcr-realestateapp:${{ env.IMAGE_TAG }}"
docker build . -t ghcr.io/${{ env.REPO_OWNER }}/ghcr-realestateapp:${{ env.IMAGE_TAG }}
- name: Push Docker image to GitHub Container Registry
run: |
echo "Pushing Image: ghcr.io/${{ env.REPO_OWNER }}/ghcr-realestateapp:${{ env.IMAGE_TAG }}"
docker push ghcr.io/${{ env.REPO_OWNER }}/ghcr-realestateapp:${{ env.IMAGE_TAG }}
- name: Tag and push Docker image with commit SHA
run: |
echo "Tagging and Pushing SHA: ${{ github.sha }}"
docker tag ghcr.io/${{ env.REPO_OWNER }}/ghcr-realestateapp:${{ env.IMAGE_TAG }} ghcr.io/${{ env.REPO_OWNER }}/ghcr-realestateapp:${{ github.sha }}
docker push ghcr.io/${{ env.REPO_OWNER }}/ghcr-realestateapp:${{ github.sha }}