Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightChaser committed Feb 2, 2024
1 parent a07759c commit 4909c66
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@
name: build and dockerize the application

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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 # Continued from the build job
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:
Expand Down

0 comments on commit 4909c66

Please sign in to comment.