fix: Fix v1 responses format #123
Workflow file for this run
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: Build and publish Docker images to GCR | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+" | |
branches: | |
- main | |
- production | |
pull_request: | |
jobs: | |
golangci: | |
name: Run golangci-lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
# Required: setup-go, for all versions v3.0.0+ of golangci-lint | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: 1.18 | |
check-latest: true | |
- uses: actions/checkout@v3 | |
- uses: technote-space/[email protected] | |
with: | |
PATTERNS: | | |
**/**.go | |
go.mod | |
go.sum | |
- uses: golangci/[email protected] | |
with: | |
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | |
version: latest | |
args: --timeout 10m | |
github-token: ${{ secrets.github_token }} | |
# Check only if there are differences in the source code | |
if: env.GIT_DIFF | |
test-unit: | |
needs: golangci | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: "1.19" | |
check-latest: true | |
- uses: actions/checkout@v3 | |
- uses: technote-space/[email protected] | |
with: | |
PATTERNS: | | |
**/**.sol | |
**/**.go | |
go.mod | |
go.sum | |
- name: Test | |
run: | | |
make test | |
if: env.GIT_DIFF | |
build: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: test-unit | |
permissions: | |
contents: read | |
id-token: write | |
packages: write | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
component: | |
- name: "api" | |
path: "." | |
dockerfile: "dockerfile" | |
image_name: "dashboard-backend_api" | |
- name: "cron" | |
path: "./cronjobs" | |
dockerfile: "dockerfile" | |
image_name: "dashboard-backend_cron" | |
- name: "nginx" | |
path: "./cors" | |
dockerfile: "compose.dockerfile" | |
image_name: "dashboard-backend_nginx" | |
env: | |
IMG_NAME: ${{ github.repository }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# - name: Debug | |
# run: | | |
# echo "github.ref -> ${{ github.ref }}" | |
# - uses: hmarr/debug-action@v2 | |
- name: Authenticate with Google Cloud | |
id: auth | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: ${{ vars.GCP_PROVIDER }} | |
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} | |
access_token_lifetime: 600s | |
- name: Docker metadata | |
id: metadata | |
uses: docker/[email protected] | |
with: | |
images: | | |
${{ vars.GCP_REGISTRY }}/${{ vars.GCP_PROJECT }}/${{ env.IMG_NAME }}/${{ matrix.component.name }} | |
ghcr.io/${{ github.repository }}/${{ matrix.component.name }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }} | |
flavor: | | |
latest=${{ github.ref == 'refs/heads/main' }} | |
# Configure docker to use the gcloud command-line tool as a credential helper | |
# This avoids using docker/login-action as a middle man. | |
- name: Configure Docker with GCloud credentials | |
shell: bash | |
run: gcloud auth configure-docker --quiet ${{ vars.GCP_REGISTRY}} | |
# Login to GitHub Container Registry (GHCR) | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/[email protected] | |
with: | |
push: true | |
tags: ${{ steps.metadata.outputs.tags }} | |
context: ${{ matrix.component.path }} | |
file: ${{ matrix.component.path }}/${{ matrix.component.dockerfile }} | |
platforms: linux/amd64 | |
- name: Write image tag to file | |
run: | | |
echo "${{ matrix.component.name }} ${{ steps.metadata.outputs.tags }}" >> metadata-${{ matrix.component.name }}.txt | |
- name: Upload image tags | |
uses: actions/upload-artifact@v2 | |
with: | |
name: image-tag-${{ matrix.component.name }} | |
path: metadata-${{ matrix.component.name }}.txt | |
- name: Clean up old images | |
uses: "docker://europe-docker.pkg.dev/gcr-cleaner/gcr-cleaner/gcr-cleaner-cli" | |
# env: | |
# GCRCLEANER_LOG: debug | |
with: | |
args: >- | |
-repo=${{ vars.GCP_REGISTRY }}/${{ vars.GCP_PROJECT }}/${{ env.IMG_NAME }}/${{ matrix.component.name }} | |
-grace=336h | |
-keep=5 | |
-tag-filter-any=^[a-zA-Z0-9-\.]+$ | |
- name: Prune old images on ghcr.io | |
uses: vlaurin/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
organization: ${{ github.repository_owner }} | |
container: backend/${{ matrix.component.name }} | |
dry-run: false | |
keep-younger-than: 14 # days | |
keep-last: 5 | |
prune-untagged: true | |
prune-tags-regexes: ^[a-zA-Z0-9-\.]+$ | |
update-deployment-tags: | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
IMG_NAME: ${{ github.repository }} | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v2 | |
with: | |
path: build-artifacts | |
- name: Clone argo-apps repo | |
run: | | |
git clone https://x-access-token:${ARGOCD_APPS_TOKEN}@${ARGOCD_APPS_REPO} APPS | |
env: | |
ARGOCD_APPS_TOKEN: ${{ secrets.ARGOCD_APPS_TOKEN }} | |
ARGOCD_APPS_REPO: ${{ secrets.ARGOCD_APPS_REPO }} | |
- name: Update k8s deployment | |
run: | | |
find build-artifacts -name "*.txt" | while read filename; do | |
while read line; do | |
COMPONENT=$(echo $line | cut -d' ' -f1) | |
NEW_IMAGE=$(echo $line | cut -d' ' -f2-) | |
sed -i "s|${{ vars.GCP_REGISTRY }}/${{ vars.GCP_PROJECT }}/${{ env.IMG_NAME }}/${COMPONENT}:[^ ]*|${NEW_IMAGE}|" APPS/${{ vars.K8S_MANIFEST }} | |
done < $filename | |
done | |
- name: Commit and push if it's necessary | |
run: | | |
cd APPS | |
git diff | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
git commit -am "Update tags (pipeline #${{ github.run_number }})" || echo "No changes to commit" | |
git push |