Skip to content

Update Docker image tagging #65

Update Docker image tagging

Update Docker image tagging #65

Workflow file for this run

name: Build and Push Docker Image
on:
push:
branches:
- main
release:
types:
- created
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: Login to GitHub Packages Docker Registry
run: echo "${{ secrets.GH_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Build and Tag Docker image
run: |
if git rev-parse --verify "refs/tags/*" >/dev/null 2>&1; then
VERSION=$(git describe --tags --abbrev=0)
else
VERSION="latest"
fi
docker build -f Dockerfile -t ashaffah/kode-pos:$VERSION .
docker tag ${{ github.repository }}:$VERSION ${{ github.repository }}:$VERSION
docker tag ${{ github.repository }}:$VERSION docker.pkg.github.com/${{ github.repository }}:$VERSION
# - name: Tag Docker Image
# run: |
# docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:latest docker.pkg.github.com/${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:latest
# docker tag ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:latest docker.pkg.github.com/${{ secrets.DOCKERHUB_USERNAME }}/${{ github.repository }}:${{ needs.determine_version.outputs.NEXT_VERSION }}
- name: Push Docker image
run: |
docker push ashaffah/kode-pos:$VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Push Docker image GitHub Packages
run: |
docker push docker.pkg.github.com/${{ github.actor }}/kode-pos:$VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Display version information
run: |
echo "Latest version: $VERSION"