Always route /projects to FEM on frontend.preview (#378) #80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy HTTP Frontend Staging | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
jobs: | |
build_image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/zooniverse/http-frontend:${{ github.sha }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
test_configuration: | |
runs-on: ubuntu-latest | |
needs: build_image | |
name: Test nginx configuration | |
container: ghcr.io/zooniverse/http-frontend:${{ github.sha }} | |
steps: | |
- name: Test nginx config inside container | |
run: | | |
# Nginx prints on stderr, redirect to stdout | |
result=$(nginx -t 2>&1) | |
status=$(echo "$result" | grep failed | wc -l) | |
if [ $status -gt 0 ]; then | |
echo "Nginx configuration test failed" | |
echo "$result" | |
exit 1 | |
else | |
echo "Nginx configuration test successful" | |
fi | |
push_latest_tag: | |
runs-on: ubuntu-latest | |
needs: test_configuration | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Tag tested image as latest | |
run: | | |
repo='ghcr.io/zooniverse/http-frontend' | |
docker pull $repo:${{ github.sha }} | |
docker tag $repo:${{ github.sha }} $repo:latest | |
docker push $repo:latest | |
deploy_nginx: | |
runs-on: ubuntu-latest | |
needs: push_latest_tag | |
steps: | |
- uses: azure/login@v2 | |
with: | |
creds: ${{ secrets.AZURE_AKS }} | |
- name: Set the target AKS cluster | |
uses: Azure/[email protected] | |
with: | |
cluster-name: microservices | |
resource-group: kubernetes | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Modify & apply template | |
run: | | |
sed "s/__IMAGE_TAG__/${{ github.sha }}/g" ./kubernetes/deployment-staging.tmpl \ | |
| kubectl apply -f - | |
deploy_slack_notification: | |
name: Deploy Slack notification | |
uses: zooniverse/ci-cd/.github/workflows/slack_notification.yaml@main | |
needs: deploy_nginx | |
if: always() | |
with: | |
commit_id: ${{ github.sha }} | |
job_name: deploy_nginx | |
status: ${{ needs.deploy_nginx.result }} | |
title: "HTTP Frontend staging deploy complete" | |
title_link: "https://static-staging.zooniverse.org" | |
secrets: | |
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} |