Merge branch 'main' of https://github.com/SkylarHoughtonGithub/go-cha… #5
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 Deploy Go App | |
on: | |
push: | |
branches: [ main ] | |
# pull_request: | |
# types: [ closed ] | |
# branches: [ main ] | |
jobs: | |
load_env: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Load environment variables | |
id: dotenv | |
run: | | |
if [ -f .env ]; then | |
export $(cat .env | xargs) | |
fi | |
echo "NAME=${NAME}" >> $GITHUB_OUTPUT | |
echo "TAGS=${TAGS}" >> $GITHUB_OUTPUT | |
outputs: | |
NAME: ${{ steps.dotenv.outputs.NAME }} | |
TAGS: ${{ steps.dotenv.outputs.TAGS }} | |
build: | |
needs: load_env | |
if: github.event.pull_request.merged == true || github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
- name: Run build script | |
run: ./build.sh ${{ needs.load_env.outputs.NAME }} | |
shell: bash | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ needs.load_env.outputs.NAME }} | |
path: ${{ needs.load_env.outputs.NAME }} | |
# docker: | |
# needs: build | |
# if: github.event.pull_request.merged == true || github.event_name == 'push' | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# - name: Download artifact | |
# uses: actions/download-artifact@v3 | |
# with: | |
# name: ${{ needs.load_env.outputs.NAME }} | |
# - name: Load environment variables | |
# id: dotenv | |
# run: | | |
# if [ -f .env ]; then | |
# export $(cat .env | xargs) | |
# fi | |
# echo "NAME=${NAME}" >> $GITHUB_OUTPUT | |
# echo "TAGS=${TAGS}" >> $GITHUB_OUTPUT | |
# outputs: | |
# NAME: ${{ steps.dotenv.outputs.NAME }} | |
# TAGS: ${{ steps.dotenv.outputs.TAGS }} | |
# - name: Set up Docker Buildx | |
# uses: docker/setup-buildx-action@v2 | |
# - name: Build and push | |
# uses: docker/build-push-action@v4 | |
# with: | |
# context: . | |
# push: false # Set to true if you want to push to a registry | |
# tags: ${{ steps.dotenv.outputs.TAGS }} |