Podman doesn't support the branch option so we need to checkout ourself to make sure the right ref is checked out.
77 lines
2.3 KiB
YAML
77 lines
2.3 KiB
YAML
on:
|
|
push:
|
|
branches:
|
|
- test
|
|
env:
|
|
REGISTRY: forge.hornwitser.no
|
|
REGISTRY_IMAGE: forge.hornwitser.no/hornwitser/schedule-demo
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: debian
|
|
container:
|
|
image: forge.hornwitser.no/hornwitser/builder:test@sha256:8458ed6dd328b1306918a45189dcb1803adade791f7040f03eff4a0c14ea21f9
|
|
steps:
|
|
-
|
|
name: debug
|
|
shell: bash
|
|
run: |
|
|
apt info podman-docker
|
|
type docker
|
|
-
|
|
name: Authenticate
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: runner
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
registry: ${{ env.REGISTRY }}
|
|
-
|
|
name: Get commit info
|
|
id: info
|
|
shell: bash
|
|
run: |
|
|
tee -a ${GITHUB_OUTPUT} <<EOF
|
|
DEPLOY_IMAGE=${{ env.REGISTRY_IMAGE }}:${{ github.ref_name }}
|
|
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 }}
|
|
-
|
|
name: Build and push
|
|
shell: bash
|
|
run: |
|
|
podman build --tag ${{ env.REGISTRY_IMAGE }}:latest ${{ github.workspace }}
|
|
podman push ${{ env.REGISTRY_IMAGE }}:latest
|
|
outputs:
|
|
DEPLOY_IMAGE: ${{ steps.info.outputs.DEPLOY_IMAGE }}
|
|
DEPLOY_BRANCH: ${{ steps.info.outputs.DEPLOY_BRANCH }}
|
|
deploy:
|
|
runs-on: docker
|
|
needs: build
|
|
container:
|
|
image: forge.hornwitser.no/hornwitser/builder:test
|
|
steps:
|
|
-
|
|
name: Check info
|
|
run: |
|
|
echo DEPLOY_IMAGE=${{ needs.build.outputs.DEPLOY_IMAGE }}
|
|
echo DEPLOY_BRANCH=${{ needs.build.outputs.DEPLOY_BRANCH }}
|
|
-
|
|
name: Configure kubectl
|
|
run: |
|
|
mkdir -p ~/.kube
|
|
cat > ~/.kube/config <<"EOF"
|
|
${{ secrets.KUBECONFIG_CONTENT }}
|
|
EOF
|
|
kubectl config view
|
|
kubectl config use-context flux-sandbox
|
|
-
|
|
name: Deploy
|
|
run: |
|
|
kubectl rollout restart \
|
|
-n schedule-demo \
|
|
deployment website
|