owltide/.forgejo/workflows/build.yaml

64 lines
2.3 KiB
YAML
Raw Normal View History

2025-02-27 22:42:28 +01:00
on:
push:
env:
2025-05-19 15:00:54 +02:00
REGISTRY_IMAGE: ${{ vars.REGISTRY }}/${{ github.repository }}:${{ github.ref_name }}
2025-02-27 22:42:28 +01:00
jobs:
build:
container:
2025-05-19 15:00:54 +02:00
image: forge.hornwitser.no/public/builder:r2025.5.2
2025-02-27 22:42:28 +01:00
steps:
2025-05-18 01:11:50 +02:00
-
2025-05-19 15:00:54 +02:00
name: Authenticate with registry
2025-05-18 01:11:50 +02:00
run: |
2025-05-19 15:00:54 +02:00
echo "${{ secrets.REGISTRY_TOKEN }}" | podman login ${{ vars.REGISTRY }} --username runner --password-stdin
2025-02-27 22:42:28 +01:00
-
name: Get commit info
id: info
shell: bash
run: |
tee -a ${GITHUB_OUTPUT} <<EOF
2025-05-19 15:00:54 +02:00
DEPLOY_IMAGE=${{ env.REGISTRY_IMAGE }}
2025-02-27 22:42:28 +01:00
DEPLOY_BRANCH=${{ github.ref_name }}
EOF
-
name: Checkout repository
run: |
git config --global credential.helper store
echo "https://runner:${{ secrets.GITHUB_TOKEN }}@$(echo "${{ github.server_url }}" | cut -b 9-)" > ~/.git-credentials
git clone --branch ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }} ${{ github.workspace }}
2025-02-27 22:42:28 +01:00
-
name: Build and push
2025-05-18 17:47:12 +02:00
shell: bash
run: |
2025-05-19 15:00:54 +02:00
podman build --tag ${{ env.REGISTRY_IMAGE }} ${{ github.workspace }}
podman push ${{ env.REGISTRY_IMAGE }}
2025-02-27 22:42:28 +01:00
outputs:
DEPLOY_IMAGE: ${{ steps.info.outputs.DEPLOY_IMAGE }}
DEPLOY_BRANCH: ${{ steps.info.outputs.DEPLOY_BRANCH }}
deploy:
needs: build
container:
2025-05-19 15:00:54 +02:00
image: forge.hornwitser.no/public/builder:r2025.5.2
2025-02-27 22:42:28 +01:00
steps:
-
name: Check info
run: |
echo DEPLOY_IMAGE=${{ needs.build.outputs.DEPLOY_IMAGE }}
echo DEPLOY_BRANCH=${{ needs.build.outputs.DEPLOY_BRANCH }}
2025-05-19 15:00:54 +02:00
# -
# name: Checkout deploy repository
# run: |
# git config --global user.email runner@noreply.hornwitser.no
# git config --global user.name Runner
# git config --global credential.helper store
# echo "https://runner:${{ secrets.DEPLOY_TOKEN }}@$(echo "${{ github.server_url }}" | cut -b 9-)" > ~/.git-credentials
# git clone ${{ github.server_url }}/hornwitser/infra.git ${{ github.workspace }}
-
name: Restart deployment
if: github.ref_name == 'develop'
2025-02-27 22:42:28 +01:00
run: |
2025-05-19 15:00:54 +02:00
curl \
-H "Authorization: ${{ secrets.WEBHOOK_RESTART_TOKEN }}"
-X POST "http://fulla.hz.hornwitser.no:9000/hooks/restart?container=schedule-demo"