Update main.yml #21
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: build and dockerize the application | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Because the .env file is not in the repository, we need to create it | |
# using the secrets.ENV_FILE secret | |
- name: Create env file | |
run: | | |
touch .env | |
echo "${{ secrets.ENV_FILE }}" > .env | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21 | |
- name: Build | |
run: go build -v . | |
- name: Upload .env file | |
uses: actions/upload-artifact@v2 | |
with: | |
name: env-file | |
path: .env | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download .env file | |
uses: actions/download-artifact@v2 | |
with: | |
name: env-file | |
path: . | |
- name: Login to Dockerhub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and release to DockerHub | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/goanonpicdb-aws:latest |