70 lines
2.2 KiB
YAML
70 lines
2.2 KiB
YAML
name: Build & Release
|
|
on:
|
|
push:
|
|
tags:
|
|
- '[0-9]+.[0-9]+.[0-9]+'
|
|
|
|
env:
|
|
ENDPOINT: services-3
|
|
STACK: mastodon
|
|
IMAGE: com.devsoap/mastobot
|
|
TAG: ${{ gitea.ref_name }}
|
|
CACHE_NAME: cache-python-dependencies-mastobot
|
|
RUNNER_TOOL_CACHE: /toolcache
|
|
|
|
jobs:
|
|
|
|
build-docker-image:
|
|
runs-on: node20
|
|
container:
|
|
image: catthehacker/ubuntu:act-20.04
|
|
steps:
|
|
- name: Checkout Docker file
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ssh-key: ${{ secrets.SSH_JOHN_PRIVATE_KEY }}
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
- name: Login to Devsoap Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ${{ secrets.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
|
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
build-args: |
|
|
VERSION=${{env.TAG}}
|
|
tags: |
|
|
${{secrets.DOCKER_REGISTRY}}/${{env.IMAGE}}:${{env.TAG}}
|
|
${{secrets.DOCKER_REGISTRY}}/${{env.IMAGE}}:latest
|
|
|
|
deploy-to-production:
|
|
if: ${{ always() && needs.build-docker-image.result == 'success' }}
|
|
needs: build-docker-image
|
|
runs-on: node20
|
|
steps:
|
|
- name: Checkout infrastructure config
|
|
run: |
|
|
git clone -v --depth=1 ${{ env.REPOSITORY_URL }} infra
|
|
env:
|
|
REPOSITORY_URL: ${{ env.GIT_REPO_USER }}@${{ env.GIT_REPO_INTERNAL }}:${{ env.DEVSOAP_INFRA_GIT_REPO }}
|
|
- name: Setup Git config
|
|
working-directory: infra
|
|
run: |
|
|
git config user.email "code@devsoap.com"
|
|
git config user.name "Devsoap Code CI/CD"
|
|
- name: Update image version
|
|
working-directory: infra
|
|
run: |
|
|
sed -i -r "s|/$IMAGE:(.*?)|/$IMAGE:$TAG|g" $ENDPOINT/$STACK/docker-compose.yml
|
|
git diff -U0
|
|
- name: Push changes
|
|
working-directory: infra
|
|
run: |
|
|
git commit -am "Updated $ENDPOINT/$STACK/$IMAGE to $TAG"
|
|
git push origin master |