Merge pull request #4 from nghenhan/feat/get-approver-from-database #9
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 Test | |
on: | |
push: | |
branches: | |
- develop | |
tags: | |
- 'v*' | |
pull_request: | |
branches: | |
- develop | |
env: | |
GCP_PROJECT_ID: <project-id> | |
GCP_REGION: asia-southeast1-b | |
IMAGE: teleport-discord-bot/teleport-discord-bot | |
jobs: | |
build-and-test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.23 | |
- name: Run tests | |
run: | | |
go test ./... | |
docker-release: | |
name: Docker Release | |
needs: build-and-test | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure Docker | |
run: | | |
gcloud auth configure-docker ${{ env.GCP_REGION }}-docker.pkg.dev | |
- name: Extract version from tag | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.IMAGE }}:latest | |
${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.IMAGE }}:${{ steps.get_version.outputs.VERSION }} | |
# - name: Create GitHub Release | |
# uses: softprops/action-gh-release@v1 | |
# with: | |
# generate_release_notes: true |