Skip to content

[merge] pull request #15 from akrck02/dev #21

[merge] pull request #15 from akrck02/dev

[merge] pull request #15 from akrck02/dev #21

# 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: publish-version
on:
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Get values for cache paths to be used in later steps
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
# Cache go build cache, used to speedup go test
- name: Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
uses: actions/cache@v2
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
# Read version from file
- name: Read version
id: version
run: echo ::set-output name=version::$(cat version.config)
# Set up Go
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.8
# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
- name: Set database running
uses: supercharge/mongodb-github-action@1.9.0
with:
mongodb-username: admin
mongodb-password: p4ssw0rd
mongodb-db: valhalla-test
mongodb-port: 27017
- name: Create env file
run: echo "IP=127.0.0.1 \n PORT=3333 \n SECRET=secret \n GIN_MODE=release \n IP_MONGODB=172.0.0.1" > .env
- name: Run tests
run: go test -v ./...
- name: Create tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.version.outputs.version }}',
sha: context.sha
})