Skip to content

Commit

Permalink
🚀 deployment: added file CI.CD #3
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Sep 24, 2023
1 parent 60d4c0c commit 6798714
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "master" ]
tags:
- "v*"
pull_request:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

create-release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') # Only run this job when a valid tag is pushed
steps:
- name: Check if tag exists
id: check_tag
run: |
if [ -n "$GITHUB_REF" ]; then
TAG=${GITHUB_REF#refs/tags/}
# echo "::set-output name=tag::$TAG"
echo "TAG=${TAG}" >> $GITHUB_ENV
else
# echo "::set-output name=tag::"
echo "TAG=" >> $GITHUB_ENV
fi
shell: bash

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
# tag_name: ${{ steps.check_tag.outputs.tag }}
tag_name: ${{ env.TAG }}
body: |
:gem: released new version ${{ env.TAG }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 6798714

Please sign in to comment.