Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Update Event “appuio-beerup-8/index” #688

Update Event “appuio-beerup-8/index”

Update Event “appuio-beerup-8/index” #688

Workflow file for this run

name: Test
on:
pull_request: {}
env:
OPENSHIFT_API: https://api.cloudscale-lpg-2.appuio.cloud:6443
HELM_RELEASE_NAME: website-pr-${{ github.event.number }}
REGISTRY_URL: registry.cloudscale-lpg-2.appuio.cloud
IMG_NAME: nginx
IMG_TAG: pr-${{ github.event.number }}
NAMESPACE: appuio-website-test
jobs:
build:
runs-on: ubuntu-latest
environment:
name: preview
steps:
- uses: actions/checkout@v3
- name: Disable auth for previews in /admin
run: yq -i 'del .backend.branch | del .backend.repo | .backend.name="test-repo"' themes/appuio/static/admin/config.yml
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY_URL }}/${{ env.NAMESPACE }}/${{ env.IMG_NAME }}
- name: Docker login
uses: docker/login-action@v2
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
with:
registry: ${{ env.REGISTRY_URL }}
username: ${{ github.repository_owner }}
password: ${{ secrets.OPENSHIFT_TOKEN }}
- name: Build image
uses: docker/build-push-action@v4
with:
context: . # this ensures we load the context from path (checkout needed)
push: ${{ !startsWith(github.head_ref, 'renovate/') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: ubuntu-latest
if: ${{ !startsWith(github.head_ref, 'renovate/') }}
needs:
- build
environment:
name: preview
url: https://${{ env.ROUTE_HOST }}
steps:
- uses: actions/checkout@v3
- name: Setup helmfile
uses: mamezou-tech/[email protected]
with:
helmfile-version: v0.144.0
install-kubectl: false
install-helm: false
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ env.OPENSHIFT_API }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
namespace: ${{ env.NAMESPACE }}
- name: Deploy app
run: helmfile -n ${{ env.NAMESPACE }} -f envs/helmfile.yaml -e preview -l component=website apply --wait
env:
HELM_RELEASE_NAME: ${{ env.HELM_RELEASE_NAME }}
IMG_TAG: ${{ env.IMG_TAG }}
GIT_SHA: ${{ github.event.pull_request.head.sha }}
- name: Gather status
run: |
ROUTE_HOST=$(oc -n ${{ env.NAMESPACE }} get route ${{ env.HELM_RELEASE_NAME }} -o jsonpath='{.spec.host}')
echo "ROUTE_HOST=$ROUTE_HOST" >> $GITHUB_ENV
curl -X POST -H "Content-Type:application/json" \
-H "Authorization: token ${{ github.token }}" \
-d '{"state": "success", "context": "Preview/Deploy", "description": "Preview deployment ready", "target_url": "https://'$ROUTE_HOST'"}' \
"https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }}"