57 lines
1.3 KiB
YAML
57 lines
1.3 KiB
YAML
name: Build and Deploy
|
|
run-name: ${{ gitea.actor }} is building ${{ gitea.repository }}
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- 'Dockerfile'
|
|
- 'composer.json'
|
|
- 'composer.lock'
|
|
- '.gitea/workflows/build-docker.yml'
|
|
- 'version'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
REGISTRY: git.nhgooi.nl
|
|
IMAGE: git.nhgooi.nl/nh_gooi/nhgooi.nl
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea Container Registry
|
|
run: |
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | \
|
|
docker login "$REGISTRY" \
|
|
-u "${{ gitea.actor }}" \
|
|
--password-stdin
|
|
|
|
- name: Build image
|
|
run: |
|
|
docker build \
|
|
-t "$IMAGE:${{ gitea.sha }}" \
|
|
-t "$IMAGE:latest" \
|
|
.
|
|
|
|
- name: Push image
|
|
run: |
|
|
docker push "$IMAGE:${{ gitea.sha }}"
|
|
docker push "$IMAGE:latest"
|
|
|
|
- name: Trigger deployment
|
|
run: |
|
|
curl --fail-with-body \
|
|
-X POST \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"image": "'"$IMAGE:${{ gitea.sha }}"'",
|
|
"commit": "${{ gitea.sha }}",
|
|
"repository": "${{ gitea.repository }}"
|
|
}' \
|
|
"${{ secrets.DEPLOY_WEBHOOK_URL }}"
|