docker image lasted #7
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': | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build_and_push: | |
name: Build and Push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Build the Docker image | |
uses: actions/checkout@v4 | |
- name: Generate sha | |
id: generate_sha | |
run: | | |
SHA=$(echo $GITHUB_SHA | head -c7) | |
echo "sha=$SHA" >> $GITHUB_OUTPUT | |
- name: Build docker image | |
run: | | |
docker build -t rogeriojr/projeto-nlw-node-fastify:${{ steps.generate_sha.outputs.sha }} . | |
- name: Log into the container register | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push image | |
run: | | |
docker push rogeriojr/projeto-nlw-node-fastify:${{ steps.generate_sha.outputs.sha }} | |
docker tag rogeriojr/projeto-nlw-node-fastify:${{ steps.generate_sha.outputs.sha }} rogeriojr/projeto-nlw-node-fastify:latest | |
docker push rogeriojr/projeto-nlw-node-fastify:latest |