feature/devops #1
72
.gitea/workflows/build-and-publish.yml
Normal file
72
.gitea/workflows/build-and-publish.yml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
name: Build and Publish Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- develop
|
||||||
|
- feature/devops
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 'lts'
|
||||||
|
|
||||||
|
- name: Log in to Docker Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.USERNAME }}
|
||||||
|
password: ${{ secrets.TOKEN }}
|
||||||
|
registry: git.3t.network
|
||||||
|
|
||||||
|
- name: Set Docker Image Tags
|
||||||
|
id: set_tags
|
||||||
|
run: |
|
||||||
|
GIT_HASH=${{env.GITHUB_SHA}}
|
||||||
|
IMAGE_NAME=git.3t.network/3t.network/ButlerBot:${GIT_HASH:0:7}
|
||||||
|
|
||||||
|
# Initialize the TAGS variable with the image name and hash
|
||||||
|
TAGS=$IMAGE_NAME
|
||||||
|
|
||||||
|
# Calculate additional tags based on branch
|
||||||
|
if [ "${{ gitea.ref_name }}" = 'main' ]; then
|
||||||
|
VERSION=$(node -p -e "require('./package.json').version)
|
||||||
|
TAGS+=",git.3t.network/3t.network/ButlerBot:latest"
|
||||||
|
TAGS+=",git.3t.network/3t.network/ButlerBot:$VERSION"
|
||||||
|
elif [ "${{ gitea.ref_name }}" = 'develop' ]; then
|
||||||
|
VERSION=$(node -p -e "require('./package.json').version)-dev
|
||||||
|
TAGS+=",git.3t.network/3t.network/ButlerBot:dev"
|
||||||
|
TAGS+=",git.3t.network/3t.network/ButlerBot:$VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Write the tags to the GITHUB_OUTPUT file to set the output
|
||||||
|
echo "image_tags=$TAGS" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.set_tags.outputs.image_tags }}
|
||||||
|
|
||||||
|
# - name: Set Portainer Webhook URL
|
||||||
|
# run: |
|
||||||
|
# if [[ "${{ gitea.ref_name }}" == "main" ]]; then
|
||||||
|
# echo "PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_URL_MAIN }}" >> $GITHUB_ENV
|
||||||
|
# elif [[ "${{ gitea.ref_name }}" == "develop" ]]; then
|
||||||
|
# echo "PORTAINER_WEBHOOK_URL=${{ secrets.PORTAINER_WEBHOOK_URL_DEV }}" >> $GITHUB_ENV
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# - name: Trigger Portainer Webhook
|
||||||
|
# run: |
|
||||||
|
# curl -X POST --silent --fail "$PORTAINER_WEBHOOK_URL"
|
||||||
|
# env:
|
||||||
|
# PORTAINER_WEBHOOK_URL: ${{ env.PORTAINER_WEBHOOK_URL }}
|
||||||
Reference in New Issue
Block a user