Skip to content

feat: implement pre-commit hook back in #44

feat: implement pre-commit hook back in

feat: implement pre-commit hook back in #44

Workflow file for this run

name: Build images and deploy to server
on:
workflow_dispatch:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-tooling:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
-
name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push image
run: |
docker build --push --progress=plain --cache-to type=inline --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/tooling:main -t ${{ env.REGISTRY }}/${{ github.repository }}/tooling:main -f docker/tooling/tooling.Dockerfile .
build-application:
needs: build-and-push-tooling
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}/tooling:main
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Composer install and NPM build
run: |
composer install --ignore-platform-reqs --optimize-autoloader --no-ansi --no-suggest --no-interaction --no-dev
npm ci
npm run production
cd node && npm install
- name: Store artifacts
uses: actions/upload-artifact@v4
with:
name: build-results
retention-days: 1
path: |
vendor
public
node
push-application:
needs: build-application
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
-
name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-results
-
name: Build and push image
run: |
docker build --push --progress=plain --cache-to type=inline --cache-from type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}/application:main -t ${{ env.REGISTRY }}/${{ github.repository }}/application:main -f docker/application/application.Dockerfile .
deploy:
needs: push-application
runs-on: ubuntu-latest
container:
image: alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy
run: |
apk add openssh-client
eval $(ssh-agent -s)
echo "${{ secrets.SSH_PRIVATE_KEY }}" | tr -d '\r' | ssh-add -
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch .env
echo "${{ vars.ENV }}" >> .env
ssh dorien@${{ vars.IP_ADDRESS }} -o StrictHostKeyChecking=no "docker login -u "${{ github.actor }}" -p "${{ secrets.GITHUB_TOKEN }}" ghcr.io"
scp -o StrictHostKeyChecking=no .env dorien@${{ vars.IP_ADDRESS }}:/home/dorien/main/.env
scp -o StrictHostKeyChecking=no docker-compose.main.yml dorien@${{ vars.IP_ADDRESS }}:/home/dorien/main/docker-compose.yml
ssh dorien@${{ vars.IP_ADDRESS }} "cd main && docker compose pull && docker compose up -d && docker image prune -af"