Merge pull request #23 from awaismohammad23/awaismohammad23-patch-6 #8
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 Build and Push | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.17 | |
- name: Build Docker image | |
run: | | |
go mod init github.com/${{ secrets.DOCKER_HUB_USERNAME }}/blockchain-assignment-1-2 | |
go build -o myapp | |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/blockchain-assignment-1-2:latest -t ${{ secrets.DOCKER_HUB_USERNAME }}/blockchain-assignment-1-2:${{ github.sha }} . | |
- name: Push Docker image to Docker Hub | |
run: | | |
echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/blockchain-assignment-1-2:latest |