cd: added k8s deployment #10
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: CI | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
name: Build and Push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22.x' | |
- name: Run tests | |
run: go test | |
- name: Generate SHA | |
id: generate_sha | |
run: | | |
SHA=$(echo $GITHUB_SHA | head -c7) | |
echo "sha=$SHA" >> $GITHUB_OUTPUT | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/nlw-api-journey:${{ steps.generate_sha.outputs.sha }} | |
${{ secrets.DOCKERHUB_USERNAME }}/nlw-api-journey:latest |