Update docker-image.yml #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: Docker Image CI | |
on: | |
push: | |
branches: [ "master" ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/[email protected] | |
- name: Install xmlstarlet | |
run: sudo apt-get install -y xmlstarlet | |
- name: Extract version | |
id: get_version | |
run: | | |
VERSION=$(xmlstarlet sel -t -v "//Project/PropertyGroup/Version" src/Sylvre.WebAPI/Sylvre.WebAPI.csproj) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Log in to GHCR | |
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Build and push | |
run: | | |
IMAGE_NAME=ghcr.io/shahzaib-m/sylvre | |
VERSION=${{ env.VERSION }} | |
docker build -f src/Sylvre.WebAPI/Dockerfile -t $IMAGE_NAME:$VERSION -t $IMAGE_NAME:latest src/ | |
docker push $IMAGE_NAME:$VERSION | |
docker push $IMAGE_NAME:latest |