Fixes swagger and api/docs handler #124
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: Master CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build-test: | |
name: Build & Test | |
runs-on: ubuntu-latest | |
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go 1.23.0 | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23.0' | |
- name: Start MongoDB | |
uses: supercharge/mongodb-github-action@1.11.0 | |
with: | |
mongodb-version: 7.0 | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: go test -p 1 -v ./... -coverprofile="coverage.out" | |
env: | |
GO_ENV: test | |
MONGODB_URI: mongodb://127.0.0.1:27017 | |
MONGO_DB: switcher-gitops-test | |
GIT_TOKEN_PRIVATE_KEY: ${{ secrets.GIT_TOKEN_PRIVATE_KEY }} | |
GIT_USER: ${{ secrets.GIT_USER }} | |
GIT_TOKEN: ${{ secrets.GIT_TOKEN }} | |
GIT_TOKEN_READ_ONLY: ${{ secrets.GIT_TOKEN_READ_ONLY }} | |
GIT_REPO_URL: ${{ secrets.GIT_REPO_URL }} | |
GIT_BRANCH: ${{ secrets.GIT_BRANCH }} | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@v3.0.0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
docker: | |
name: Publish Docker Image | |
needs: [ build-test ] | |
runs-on: ubuntu-latest | |
if: success() && github.ref == 'refs/heads/master' | |
outputs: | |
digest: ${{ steps.docker_build.outputs.digest }} | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: trackerforce/switcher-gitops:latest | |
update-kustomize: | |
name: Deploy | |
needs: [ docker ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: 'master' | |
- name: Checkout Kustomize | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.ARGOCD_PAT }} | |
repository: switcherapi/switcher-deployment | |
ref: master | |
- name: Set up arkade-get | |
uses: alexellis/arkade-get@master | |
with: | |
kubectl: latest | |
kustomize: latest | |
- name: Update GitOps repository | |
run: | | |
cd switcher-gitops/base | |
echo RELEASE_TIME=`date` > environment-properties.env | |
kustomize edit set image trackerforce/switcher-gitops:latest=trackerforce/switcher-gitops@${{ needs.docker.outputs.digest }} | |
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | |
git config --global user.name "${{ github.actor }}" | |
git add . | |
git commit -m "[argocd] switcher-gitops: ${{ needs.docker.outputs.digest }}" | |
git push |