docs: update README.md to reflect new server port and add external se… #5
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: CI/CD Pipeline | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
branches: [ main ] | |
env: | |
GO_VERSION: 1.23 | |
DOCKER_IMAGE: docker.io/raufzer/dz-jobs-api-docker | |
RAILWAY_SERVICE: dz-jobs-api | |
jobs: | |
test: | |
name: Test and Lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install Swagger | |
run: go install github.com/swaggo/swag/cmd/swag@latest | |
- name: Generate Swagger Docs | |
run: swag init -g cmd/server/main.go -o docs | |
- name: Run tests | |
run: go test -v ./... | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
args: --timeout 5m | |
- name: Security audit | |
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./... | |
build-docker: | |
name: Build and Push Docker Image | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Extract version tag | |
id: extract_tag | |
run: | | |
# Extract the tag name from the Git reference (e.g., refs/tags/v1.1.5) | |
TAG_NAME=${GITHUB_REF#refs/tags/} | |
echo "Extracted tag: $TAG_NAME" | |
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ env.DOCKER_IMAGE }}:${{ steps.extract_tag.outputs.tag_name }} | |
${{ env.DOCKER_IMAGE }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
deploy: | |
name: Deploy to Railway | |
needs: build-docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Railway CLI | |
run: npm install -g @railway/cli | |
- name: Deploy to Railway | |
run: railway up --service ${{ secrets.RAILWAY_SERVICE_ID }} --detach | |
env: | |
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} |