ci: implement push latest image process #35
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: | |
pull_request: | |
branches: ['main'] | |
paths: | |
- 'Dockerfile' | |
- 'scripts/*' | |
- '.github/workflows/*' | |
push: | |
branches: ['main'] | |
paths: | |
- 'Dockerfile' | |
- 'scripts/*' | |
- '.github/workflows/*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build the Docker image | |
run: docker build . --file Dockerfile --tag "devops-toolkit-merge:$GITHUB_SHA" | |
- name: Verify tool versions | |
run: | | |
cd scripts | |
chmod +x check_version_in_toolkit.sh | |
./check_version_in_toolkit.sh "devops-toolkit-merge:$GITHUB_SHA" | |
- name: Push Docker Image | |
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
docker tag "devops-toolkit-merge:$GITHUB_SHA" "tungbq/devops-toolkit:main-${GITHUB_SHA::7}" | |
# docker push "tungbq/devops-toolkit:main-${GITHUB_SHA::7}" |