feat: updated course catalog pills w resp. design #57
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: Container ECR build + deploy | |
on: | |
push: | |
branches: | |
- main | |
- demo | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
setup-env: | |
if: github.repository == 'UnlockedLabs/UnlockEdv2' || github.repository == 'PThorpe92/UnlockEdv2' | |
runs-on: ubuntu-latest | |
outputs: | |
frontend_changes: ${{ steps.frontend_changes.outputs.changed }} | |
backend_changes: ${{ steps.backend_changes.outputs.changed }} | |
middleware_changes: ${{ steps.middleware_changes.outputs.changed }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 3 | |
- id: frontend_changes | |
run: | | |
echo "changed=$(git diff --name-only HEAD~1 | grep '^frontend/' | wc -l)" >> $GITHUB_OUTPUT | |
- id: backend_changes | |
run: | | |
echo "changed=$(git diff --name-only HEAD~1 | grep '^backend/' | wc -l)" >> $GITHUB_OUTPUT | |
- id: middleware_changes | |
run: | | |
echo "changed=$(git diff --name-only HEAD~1 | grep '^provider-middleware/' | wc -l)" >> $GITHUB_OUTPUT | |
- name: Debug outputs | |
run: | | |
echo "Frontend changes: ${{ steps.frontend_changes.outputs.changed }}" | |
echo "Backend changes: ${{ steps.backend_changes.outputs.changed }}" | |
echo "Middleware changes: ${{ steps.middleware_changes.outputs.changed }}" | |
build-and-push: | |
if: github.repository == 'UnlockedLabs/UnlockEdv2' || github.repository == 'PThorpe92/UnlockEdv2' | |
needs: setup-env | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_IAM_ROLE }} | |
aws-region: us-west-2 | |
mask-aws-account-id: true | |
- name: Log in to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push frontend image | |
if: ${{ needs.setup-env.outputs.frontend_changes != '0' }} && github.ref == 'refs/heads/main' | |
run: | | |
docker buildx build --platform linux/amd64 -t=${{ steps.login-ecr.outputs.registry }}/frontend:latest --push frontend/. | |
- name: Build and push backend image | |
if: ${{ needs.setup-env.outputs.backend_changes != '0' }} && github.ref == 'refs/heads/main' | |
run: | | |
docker buildx build --platform linux/amd64 -t=${{ steps.login-ecr.outputs.registry }}/unlockedv2:latest --push -f backend/Dockerfile . | |
- name: Build and push middleware image | |
if: ${{ needs.setup-env.outputs.middleware_changes != '0' }} && github.ref == 'refs/heads/main' | |
run: | | |
docker buildx build --platform linux/amd64 -t=${{ steps.login-ecr.outputs.registry }}/provider_middleware:latest --push -f provider-middleware/Dockerfile . | |
- name: Set up kubectl | |
uses: azure/setup-kubectl@v1 | |
with: | |
version: v1.21.0 | |
- name: Set up Kubeconfig Staging | |
if: github.ref == 'refs/heads/main' | |
run: | | |
mkdir -p $HOME/.kube && touch $HOME/.kube/config | |
echo "${{ secrets.KUBECTL_CONFIG }}" | base64 -d > $HOME/.kube/config | |
- name: Set up Kubeconfig Demo | |
if: github.ref == 'refs/heads/demo' | |
run: | | |
mkdir -p $HOME/.kube && touch $HOME/.kube/config | |
echo "${{ secrets.KUBECTL_CONFIG_DEMO }}" | base64 -d > $HOME/.kube/config | |
- name: Create k8s ECR secret | |
run: | | |
kubectl delete secret ecr-secret --ignore-not-found | |
kubectl create secret docker-registry ecr-secret \ | |
--docker-server=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-west-2.amazonaws.com \ | |
--docker-username=AWS \ | |
--docker-password=$(aws ecr get-login-password --region us-west-2) \ | |
--docker-email=none | |
- name: restart frontend | |
if: ${{ needs.setup-env.outputs.frontend_changes != '0' }} | |
run: | | |
kubectl rollout restart deployment frontend | |
- name: restart server | |
if: ${{ needs.setup-env.outputs.backend_changes != '0' }} | |
run: | | |
kubectl rollout restart deployment server | |
- name: restart provider_middleware | |
if: ${{ needs.setup-env.outputs.middleware_changes != '0' }} | |
run: | | |
kubectl rollout restart deployment provider-service |