Merge pull request #3 from ItsRaelx/main #1
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: Docker Image CI | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Convert IMAGE_NAME to lowercase | |
run: | | |
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> $GITHUB_ENV | |
- name: Build the Docker image | |
run: | | |
docker build . --file Dockerfile --tag $IMAGE_NAME:${{ github.sha }} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Tag the image with the 'latest' tag | |
run: | | |
docker tag $IMAGE_NAME:${{ github.sha }} ghcr.io/$IMAGE_NAME:latest | |
- name: Tag the image with the SHA | |
run: | | |
docker tag $IMAGE_NAME:${{ github.sha }} ghcr.io/$IMAGE_NAME:${{ github.sha }} | |
- name: Push the Docker image to GitHub Container Registry | |
run: | | |
docker push ghcr.io/$IMAGE_NAME:latest | |
docker push ghcr.io/$IMAGE_NAME:${{ github.sha }} |