chore: update releases [ci skip]
This commit is contained in:
124
.gitea/workflows/deploy.yml
Normal file
124
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,124 @@
|
||||
name: "Portainer CI/CD Pipeline"
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
stack-name:
|
||||
description: "Name of the Portainer stack to deploy"
|
||||
required: true
|
||||
type: string
|
||||
portainer-url:
|
||||
description: "Base URL of the Portainer API (e.g. https://portainer.example.com/api)"
|
||||
required: true
|
||||
type: string
|
||||
portainer-endpoint:
|
||||
description: "Portainer endpoint ID"
|
||||
required: true
|
||||
type: string
|
||||
repo-compose-file:
|
||||
description: "Path to docker-compose file"
|
||||
required: false
|
||||
default: "docker-compose.yml"
|
||||
type: string
|
||||
image-name:
|
||||
description: "Docker image name"
|
||||
required: true
|
||||
type: string
|
||||
registry-url:
|
||||
description: "Docker registry URL (e.g. ghcr.io)"
|
||||
required: true
|
||||
type: string
|
||||
secrets:
|
||||
REGISTRY_USERNAME:
|
||||
description: "Docker registry username"
|
||||
required: true
|
||||
REGISTRY_PASSWORD:
|
||||
description: "Docker registry password"
|
||||
required: true
|
||||
CI_GITEA_TOKEN:
|
||||
description: "Token for version bump and push"
|
||||
required: true
|
||||
PORTAINER_TOKEN:
|
||||
description: "Portainer API token"
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
# --------------------------------------------------------
|
||||
# Semantic Release (Version bump + changelog)
|
||||
# --------------------------------------------------------
|
||||
release:
|
||||
name: Semantic Release
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.CI_GITEA_TOKEN }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.CI_GITEA_TOKEN }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install semantic-release
|
||||
run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/exec
|
||||
|
||||
- name: Run semantic-release
|
||||
run: npx semantic-release
|
||||
env:
|
||||
GIT_AUTHOR_NAME: "CI Bot"
|
||||
GIT_AUTHOR_EMAIL: "ci@etwo.dev"
|
||||
GIT_COMMITTER_NAME: "CI Bot"
|
||||
GIT_COMMITTER_EMAIL: "ci@etwo.dev"
|
||||
IMAGE_NAME: ${{ inputs.image-name }}
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Build and Push Docker Image
|
||||
# --------------------------------------------------------
|
||||
build:
|
||||
name: Build and Push Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
IMAGE_NAME: ${{ inputs.image-name }}
|
||||
REGISTRY_URL: ${{ inputs.registry-url }}
|
||||
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
|
||||
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Docker registry
|
||||
run: |
|
||||
echo "$REGISTRY_PASSWORD" | docker login $REGISTRY_URL -u "$REGISTRY_USERNAME" --password-stdin
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
VERSION=$(cat .release-version 2>/dev/null || echo "latest")
|
||||
echo "Building docker image with tag $VERSION"
|
||||
docker build -t $REGISTRY_URL/${IMAGE_NAME}:$VERSION .
|
||||
docker push $REGISTRY_URL/${IMAGE_NAME}:$VERSION
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Deploy to Portainer (using your Action)
|
||||
# --------------------------------------------------------
|
||||
deploy:
|
||||
name: Deploy to Portainer
|
||||
runs-on: ubuntu-latest
|
||||
needs: release
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy stack via Portainer API
|
||||
uses: actions/portable@v1
|
||||
with:
|
||||
portainer-url: ${{ inputs.portainer-url }}
|
||||
portainer-token: ${{ secrets.PORTAINER_TOKEN }}
|
||||
portainer-endpoint: ${{ inputs.portainer-endpoint }}
|
||||
stack-name: ${{ inputs.stack-name }}
|
||||
repo-url: ${{ github.server_url }}/${{ github.repository }}
|
||||
repo-ref: ${{ github.ref }}
|
||||
repo-compose-file: ${{ inputs.repo-compose-file }}
|
||||
Reference in New Issue
Block a user