Skip to content

Commit

Permalink
added version, docker-publish and go-check workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
OS-M committed May 26, 2022
1 parent 0e8d284 commit d9bd209
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 1 deletion.
57 changes: 57 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: docker-publish
on:
workflow_call:
inputs:
appName:
required: true
type: string
dockerfilePath:
required: false
default: ./Dockerfile
type: string
dockerRepo:
required: false
default: proxima.one/services
type: string
secrets:
DOCKER_REGISTRY_URL:
required: false
DOCKER_USERNAME:
required: false
DOCKER_PASSWORD:
required: false
PROXIMA_GITHUB_USER:
required: false
PROXIMA_GITHUB_TOKEN:
required: false

jobs:
version:
uses: proxima-one/github-workflows/.github/workflows/version.yml@master
with:
appName: ${{ inputs.appName }}
dockerRepo: ${{ inputs.dockerRepo }}
secrets:
DOCKER_REGISTRY_URL: ${{ secrets.DOCKER_REGISTRY_URL }}

publish:
needs: version
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Write .netrc"
run: echo "machine github.com login ${{ secrets.PROXIMA_GITHUB_USER }} password ${{ secrets.PROXIMA_GITHUB_TOKEN }}" > ./.netrc

- name: "Docker Login"
run: docker login -u="${{ secrets.DOCKER_USERNAME }}" -p="${{ secrets.DOCKER_PASSWORD }}" ${{ secrets.DOCKER_REGISTRY_URL }}

- name: Build Image
run: |
DOCKER_BUILDKIT=1 docker build . --build-arg BUILD_VERSION=${{ needs.version.outputs.VERSION }} --tag image --file ${{ inputs.dockerfilePath }} --target prod --progress=plain
- name: Push image
run: |
docker tag image ${{ needs.version.outputs.IMAGE_FULL_NAME }}
docker push ${{ needs.version.outputs.IMAGE_FULL_NAME }}
34 changes: 34 additions & 0 deletions .github/workflows/go-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: go-check
on:
workflow_call:
secrets:
PROXIMA_GITHUB_TOKEN:
required: true

jobs:
quick-check:
name: Golang Tests
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/proxima-one/block-indexer-api/api
PROXIMA_GITHUB_TOKEN: ${{ secrets.PROXIMA_GITHUB_TOKEN }}
defaults:
run:
working-directory: .
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Checkout Code
uses: actions/checkout@v2

- name: Setup credentials
run: git config --global url.https://[email protected]/.insteadOf https://github.com/

- name: Install dependencies
run: go get ./...

- name: Unit Tests
run: go test --short ./...
2 changes: 1 addition & 1 deletion .github/workflows/go-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ jobs:
App: ${{ inputs.appName }}
Version: ${{ steps.version.outputs.IMAGE_TAG }}
Image: ${{ steps.version.outputs.IMAGE_FULL_NAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: read-version
on:
workflow_call:
inputs:
appName:
required: true
type: string
dockerRepo:
required: true
type: string
secrets:
DOCKER_REGISTRY_URL:
required: true
outputs:
version:
description: "Version of image"
value: ${{ jobs.readVersion.outputs.version }}
imageTag:
description: "Image tag of image"
value: ${{ jobs.readVersion.outputs.imageTag }}
imageId:
description: "Id (url without Docker registry) of image"
value: ${{ jobs.readVersion.outputs.imageId }}

jobs:
readVersion:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.VERSION }}
imageTag: ${{ steps.version.outputs.IMAGE_TAG }}
imageId: ${{ steps.version.outputs.IMAGE_ID }}
steps:
- name: "Read Version"
id: version
run: |
VERSION=$(cat ./VERSION)
IMAGE_TAG=${{ inputs.appName }}-$VERSION-${GITHUB_SHA::7}
IMAGE_ID=/${{ inputs.dockerRepo }}:$IMAGE_TAG
IMAGE_FULL_NAME=${{ secrets.DOCKER_REGISTRY_URL }}$IMAGE_ID
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID
echo IMAGE_FULL_NAME=$IMAGE_FULL_NAME
echo IMAGE_TAG=$IMAGE_TAG
echo "::set-output name=VERSION::$VERSION"
echo "::set-output name=IMAGE_TAG::$IMAGE_TAG"
echo "::set-output name=IMAGE_FULL_NAME::$IMAGE_FULL_NAME"
echo "::set-output name=IMAGE_ID::$IMAGE_ID"
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/github-workflows.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9bd209

Please sign in to comment.