Skip to content

Merge pull request #76 from bennetrr/main #39

Merge pull request #76 from bennetrr/main

Merge pull request #76 from bennetrr/main #39

Workflow file for this run

name: Release
on:
push:
branches:
- release
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
next-version: ${{ steps.get-release-version.outputs.version }}
next-version-name: ${{ steps.get-release-version.outputs.version-name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wemogy/get-release-version-action@v4.3.2
id: get-release-version
with:
prefix: v
create-tag: 'true'
git-username: bennetrr
git-email: bennet@bennetr.me
mode: semantic
build-frontend:
name: Build frontend containers
needs:
- setup
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
platform:
- { docker: linux/amd64 }
- { docker: linux/arm64 }
- { docker: linux/arm64/v8 }
steps:
- uses: actions/checkout@v4
- name: Build container
uses: ./.github/actions/containers/build
with:
registry-server: ghcr.io
registry-user: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
name: bennetrr/brickinv-frontend
version: ${{ needs.setup.outputs.next-version-name }}
context: src/frontend
push: 'true'
docker-platform: ${{ matrix.platform.docker }}
build-backend:
name: Build backend containers
needs:
- setup
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
platform:
- { docker: linux/amd64, dotnet: amd64, dotnet-ef: linux-x64 }
- { docker: linux/arm64, dotnet: arm64, dotnet-ef: linux-arm64 }
- { docker: linux/arm64/v8, dotnet: arm64, dotnet-ef: linux-arm64 }
steps:
- uses: actions/checkout@v4
- name: Build container
uses: ./.github/actions/containers/build
with:
registry-server: ghcr.io
registry-user: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
name: bennetrr/brickinv-backend
version: ${{ needs.setup.outputs.next-version-name }}
context: src/backend/
push: 'true'
docker-platform: ${{ matrix.platform.docker }}
dotnet-platform: ${{ matrix.platform.dotnet }}
dotnet-ef-platform: ${{ matrix.platform.dotnet-ef }}
merge-frontend:
name: Merge frontend containers
needs:
- setup
- build-frontend
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Merge and push containers
uses: ./.github/actions/containers/merge
with:
registry-server: ghcr.io
registry-user: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
name: bennetrr/brickinv-frontend
version: ${{ needs.setup.outputs.next-version-name }}
merge-backend:
name: Merge backend containers
needs:
- setup
- build-backend
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Merge and push container
uses: ./.github/actions/containers/merge
with:
registry-server: ghcr.io
registry-user: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
name: bennetrr/brickinv-backend
version: ${{ needs.setup.outputs.next-version-name }}
github-release:
name: Create GitHub release
needs:
- setup
- merge-frontend
- merge-backend
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
name: Version ${{ needs.setup.outputs.next-version }}
tag: ${{ needs.setup.outputs.next-version-name }}
prerelease: ${{ github.event.inputs.pre-release || false }}
generateReleaseNotes: true
commit: ${{ github.head_ref || github.ref_name }}
deploy:
# Thanks to https://www.programonaut.com/how-to-deploy-a-git-repository-to-a-server-using-github-actions/
name: Deploy to production
needs:
- setup
- merge-frontend
- merge-backend
runs-on: ubuntu-latest
steps:
- name: Install ssh keys
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.DEPLOY_SSH_HOST }} > ~/.ssh/known_hosts
- name: Pull
run: |
ssh ${{ secrets.DEPLOY_SSH_USER }}@${{ secrets.DEPLOY_SSH_HOST }} "
cd ${{ secrets.DEPLOY_WORKDIR }}
sed -i -E 's/ghcr\.io\/bennetrr\/brickinv-(frontend|backend):v[0-9]+\.[0-9]+\.[0-9]+/ghcr.io\/bennetrr\/brickinv-\1:${{ needs.setup.outputs.next-version-name }}/g' docker-compose.yml
docker compose up -d
exit
"