mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
This commit introduces a `Makefile` to standardize the build, test, and linting process, as suggested in the `TODO.md` file. The `Makefile` includes targets for `lint`, `test`, and `test-integration`. The `.github/workflows/ci.yml` file has been updated to use the `make test-integration` target, simplifying the CI configuration. The `.github/workflows/cd.yml` file has been updated to be ready for deployment to a staging environment. It now calls a `make deploy-staging` target, which serves as a placeholder for the actual deployment script. This work addresses the 'Establish a CI/CD Pipeline' task from the `TODO.md`.
74 lines
2.0 KiB
YAML
74 lines
2.0 KiB
YAML
name: Go CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ["v*"]
|
|
|
|
jobs:
|
|
build-and-push:
|
|
name: Build and Push Docker Image
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ghcr.io/${{ github.repository }}
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,format=long
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
deploy-staging:
|
|
name: Deploy to Staging
|
|
needs: build-and-push
|
|
runs-on: ubuntu-latest
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@v4
|
|
|
|
# This step runs the deployment command from the Makefile.
|
|
# You will need to add secrets to your GitHub repository for this to work.
|
|
# For example, SSH_PRIVATE_KEY, STAGING_HOST, etc.
|
|
- name: Deploy to staging
|
|
run: make deploy-staging
|
|
env:
|
|
# Example of how you might pass the tag to the makefile
|
|
TAG: ${{ github.ref_name }}
|
|
# Add other environment variables/secrets needed for deployment
|
|
# STAGING_HOST: ${{ secrets.STAGING_HOST }}
|
|
# STAGING_USER: ${{ secrets.STAGING_USER }}
|
|
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|