update .gitignore #9
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 Deploy | |
on: | |
push: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set date tag | |
run: echo "DATE_TAG=$(date +%s)" >> $GITHUB_ENV | |
- name: Build the Docker image | |
run: | | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.DATE_TAG }} . | |
- name: Tag the Docker image | |
run: | | |
# Tag with timestamp | |
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.DATE_TAG }} ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.DATE_TAG }} | |
# Tag as latest | |
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.DATE_TAG }} ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:latest | |
- name: Push the Docker image | |
run: | | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:${{ env.DATE_TAG }} | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/todo-api:latest |