Created using Colaboratory #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
# from https://faun.pub/how-to-push-docker-image-using-github-actions-694397c4f557 | |
name: This a workflow title | |
on: [push] # When pushing to any branch then run this action | |
# Env variable | |
env: | |
DOCKER_USER: ${{secrets.DOCKER_USER}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | |
REPO_NAME: ${{secrets.REPO_NAME}} | |
jobs: | |
push-image-to-docker-hub: # job name | |
runs-on: ubuntu-latest # runner name : (ubuntu latest version) | |
steps: | |
- name: Get Date | |
id: date # This ID is used to refer to the output of this step in subsequent steps | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d--%H-%M-%S')" | |
- uses: actions/checkout@v3 # first action : checkout source code | |
- name: docker login | |
run: | # log into docker hub account | |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | |
- name: Build the Docker image # push The image to the docker hub | |
run: docker build . --file Dockerfile --tag $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }} && docker build . --file Dockerfile --tag $DOCKER_USER/$REPO_NAME:latest | |
- name: Docker Push | |
run: docker push $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }} && docker push $DOCKER_USER/$REPO_NAME:latest |