Skip to content

Merge pull request #383 from green-ecolution/feature/transactions-sen… #219

Merge pull request #383 from green-ecolution/feature/transactions-sen…

Merge pull request #383 from green-ecolution/feature/transactions-sen… #219

name: Build and Push Docker Image Develop
"on":
push:
branches:
- develop
jobs:
update_test_cover_badge:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Dependencies
run: sudo apt-get update && sudo apt-get install -y make build-essential libgeos-dev libproj-dev
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Setup
run: make setup/ci
- name: Build
run: make build
- name: generate test coverage
run: go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
- name: check test coverage
uses: vladopajic/go-test-coverage@v2
with:
profile: cover.out
local-prefix: github.com/green-ecolution/green-ecolution-backend
git-token: ${{ github.ref_name == 'develop' && secrets.GITHUB_TOKEN || '' }}
git-branch: badges
build_and_deploy_dev:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
actions: write
outputs:
COMMIT_SHA: ${{ steps.set_commit_sha.outputs.COMMIT_SHA }}
APP_VERSION: ${{ steps.set_app_version.outputs.APP_VERSION }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set commit sha
id: set_commit_sha
run: |
COMMIT_SHA=$(git rev-parse --short $GITHUB_SHA)
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_OUTPUT
- name: Set app version
id: set_app_version
run: |
APP_VERSION=$(git describe --tags --always --dirty)
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV
echo "APP_VERSION=$APP_VERSION" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set lower case owner name
run: |
echo "REPO_LC=${REPO,,}" >>${GITHUB_ENV}
env:
REPO: "${{ github.repository }}"
- name: get build time
run: |
echo "BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >>${GITHUB_ENV}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
build-args: |
APP_VERSION=${{env.APP_VERSION}}
APP_GIT_COMMIT=${{env.COMMIT_SHA}}
APP_GIT_BRANCH=develop
APP_BUILD_TIME=${{env.BUILD_TIME}}
APP_GIT_REPOSITORY=${{github.repository}}
file: ./.docker/Dockerfile.dev
platforms: linux/amd64 # ,linux/arm64
push: true
tags: ghcr.io/${{ env.REPO_LC }}-dev:latest, ghcr.io/${{ env.REPO_LC }}-dev:${{ env.COMMIT_SHA }}
- name: Notify management repo to update submodules
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GREEN_ECOLUTION_PAT }}
repository: green-ecolution/green-ecolution-management
event-type: "update-submodules"
check_api_docs:
name: Check API Docs
needs: build_and_deploy_dev
env:
COMMIT_SHA: ${{ needs.build_and_deploy_dev.outputs.COMMIT_SHA }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install dependencies
run: make setup/ci
- name: Go generate
run: make generate
- name: Move swagger docs
run: mv ./docs/swagger.json ./docs/api-docs.json
- name: Get api docs artifacts
env:
GH_TOKEN: ${{ secrets.GREEN_ECOLUTION_PAT }}
run: |
gh run download -R green-ecolution/green-ecolution-backend -n api-docs.json
- name: Check API Docs exist
run: |
if [ ! -f ./api-docs.json ]; then
echo "api-docs.json not found"
touch api-docs.json
else
echo "api-docs.json found"
fi
- name: Check API Docs Diff
run: |
diff ./docs/api-docs.json ./api-docs.json && echo "up-to-date=true" >> $GITHUB_ENV || echo "up-to-date=false" >> $GITHUB_ENV
- name: Upload API Docs
if: env.up-to-date == 'false'
uses: actions/upload-artifact@v4
with:
name: api-docs.json
path: ./docs/api-docs.json
- name: Create PR in frontend repo
if: env.up-to-date == 'false'
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.GREEN_ECOLUTION_PAT }}
repository: green-ecolution/green-ecolution-frontend
event-type: "api-docs-update"
client-payload: '{"hash": "${{ env.COMMIT_SHA }}"}'