- You just need to set up
RENDER_DEPLOY_HOOK_URL
,DOCKER_USER
,DOCKER_PASSWORD
,REPO_NAME
secrets in Settings.
And go in folder where
Dockerfile
is, in my casebackend/
folder
run: docker build backend/ --file backend/Dockerfile --tag $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }}
name: Deploy docker starting
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Env variable
env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
REPO_NAME: ${{secrets.REPO_NAME}}
deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
jobs:
push-image-to-docker-hub: # job name
runs-on: ubuntu-latest # runner name : (ubuntu latest version)
steps:
- uses: actions/checkout@v2 # first action : checkout source code
- name: docker login
run: | # log into docker hub account
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
- name: Get current date # get the date of the build
id: date
run: echo "date=$(date +'%Y-%m-%d--%M-%S')" >> $GITHUB_OUTPUT
- name: Build the Docker image # push The image to the docker hub
run: docker build backend/ --file backend/Dockerfile --tag $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }}
- name: Docker Push
run: docker push $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }}
# https://render.com/docs/deploy-hooks#using-with-github-actions
- name: Deploy on Render
run:
curl "$deploy_url"
maybe it should use
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
Top comments (0)