generated from alecodes/base-template
chore: add build workflow
This commit is contained in:
parent
6288969c4d
commit
059d6a5a94
4 changed files with 140 additions and 1 deletions
69
.forgejo/workflows/build-docker-image.yaml
Normal file
69
.forgejo/workflows/build-docker-image.yaml
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
name: Publish image
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
create-docker-images:
|
||||
runs-on: host
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.alecodes.page
|
||||
username: ${{ vars.CONTAINER_REGISTRY_USER }}
|
||||
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
file: ./docker/Dockerfile
|
||||
tags: |
|
||||
git.alecodes.page/alecodes/index:latest
|
||||
git.alecodes.page/alecodes/index:${{ github.sha }}
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- create-docker-images
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
- name: 'Docker Stack Deploy'
|
||||
uses: https://github.com/cssnr/stack-deploy-action@v1
|
||||
with:
|
||||
host: ${{ vars.DOCKER_SWARM_HOST }}
|
||||
port: ${{ vars.DOCKER_SWARM_PORT }}
|
||||
user: ${{ secrets.DOCKER_SWARM_USER }}
|
||||
ssh_key: '${{ secrets.DOCKER_SWARM_SSH_KEY }}'
|
||||
file: 'docker/docker-stack.yaml'
|
||||
name: 'index'
|
||||
|
||||
rebase:
|
||||
runs-on: ubuntu-latest
|
||||
needs: deploy
|
||||
if: success()
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
ref: content-update
|
||||
|
||||
- name: Update branch
|
||||
run: |
|
||||
set -x
|
||||
git config --global user.name "robo"
|
||||
git config --global user.email "robo@alecodes.page"
|
||||
git rebase origin/main
|
||||
git push origin content-update --force-with-lease
|
||||
Loading…
Add table
Add a link
Reference in a new issue