From 4909c667f9b5322aca44fb8b69c4b298a9fc193c Mon Sep 17 00:00:00 2001 From: Lee Garam Date: Fri, 2 Feb 2024 16:00:47 +0900 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a602650..c90a8c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: