Skip to content

chore(gomod): bump the gomod-dependencies group across 1 directory wi… #8

chore(gomod): bump the gomod-dependencies group across 1 directory wi…

chore(gomod): bump the gomod-dependencies group across 1 directory wi… #8

Workflow file for this run

name: Push on main branch
on:
push:
branches: [ main ]
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'server/go.mod'
cache: true
cache-dependency-path: 'server/go.sum'
- name: Test
run: go test -v ./...
working-directory: server
auto-tag:
name: Auto-Tag
needs: test
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
image-tag: ${{ steps.tagger.outputs.new_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run auto tag script
run: |
git config user.name "GitHub Actions"
git config user.email "github-actions@github.com"
./scripts/auto_tag.sh
- name: Get the new tag without 'v' prefix
id: tagger
run: |
NEW_TAG=$(git describe --tags --abbrev=0)
NEW_TAG_WITHOUT_V=${NEW_TAG#v}
echo "new_tag=$NEW_TAG_WITHOUT_V" >> $GITHUB_OUTPUT
build-and-publish:
name: Build and Publish
needs: auto-tag
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image-tag: ${{ steps.tagger.outputs.image_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Save image tag
id: tagger
run: |
echo "image_tag=${{ needs.auto-tag.outputs.image-tag }}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: server
push: true
tags: |
ghcr.io/${{ github.repository }}/server:${{ needs.auto-tag.outputs.image-tag }}
ghcr.io/${{ github.repository }}/server:latest-rc
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy UAT
needs: build-and-publish
runs-on: ubuntu-latest
permissions:
contents: read
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER_NAME: uat
GKE_CLUSTER_ZONE: europe-central2
GKE_BASTION_NAME: gke-uat-bastion
GKE_BASTION_ZONE: europe-central2-a
HELM_NAMESPACE: clearnet-uat
HELM_RELEASE: faucet-app
HELM_CONFIG_ENV: uat
KUBECONFIG: kubeconfig.conf
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.GKE_UAT_SA_KEY }}'
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.GKE_PROJECT }}
install_components: gke-gcloud-auth-plugin
- name: Get GKE credentials
run: |-
gcloud container clusters get-credentials ${GKE_CLUSTER_NAME} \
--project ${PROJECT_ID} \
--zone ${GKE_CLUSTER_ZONE} \
--internal-ip
- name: Port-forward to GKE Bastion
run: |-
gcloud compute ssh ${GKE_BASTION_NAME} \
--tunnel-through-iap \
--project ${PROJECT_ID} \
--zone ${GKE_BASTION_ZONE} \
--ssh-key-expiration=600s \
-- -NL8888:127.0.0.1:8888 &
sleep 5
- name: Install Helm
uses: azure/setup-helm@v4
- name: Release
env:
HTTPS_PROXY: http://localhost:8888
run: |-
helm upgrade -i ${HELM_RELEASE} chart \
-n ${HELM_NAMESPACE} \
--reuse-values \
-f chart/config/${HELM_CONFIG_ENV}/values.yaml \
--set image.tag="${{ needs.build-and-publish.outputs.image-tag }}"
notify-slack:
name: Notify Slack
runs-on: ubuntu-latest
needs: [deploy]
if: always()
steps:
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_CHANNEL: deployments
SLACK_USERNAME: CI/CD Bot
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || contains(needs.*.result, 'cancelled') && 'cancelled' || 'success' }}
SLACK_ICON_EMOJI: ${{ contains(needs.*.result, 'failure') && ':x:' || contains(needs.*.result, 'cancelled') && ':warning:' || ':white_check_mark:' }}
SLACK_TITLE: '🚰 🛫 Faucet App Release Candidate 🛬 🚰'
SLACK_MESSAGE_ON_SUCCESS: |
✅ RC build and deployment completed successfully!
${{github.event.head_commit.message}}
SLACK_MESSAGE_ON_FAILURE: |
❌ RC build or deployment failed!
${{github.event.head_commit.message}}
SLACK_MESSAGE_ON_CANCEL: |
⚠️ RC build or deployment was cancelled!
${{github.event.head_commit.message}}
SLACK_FOOTER: 'Faucet App CI/CD Pipeline'