NS-request-assistance flag on Admin list page #415
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: CI | |
on: | |
workflow_call: | |
inputs: | |
push_docker_image: | |
type: string # true or false | |
default: "false" | |
outputs: | |
docker_image_name: | |
description: "Only docker image name" | |
value: ${{ jobs.test.outputs.docker_image_name }} | |
docker_image_tag: | |
description: "Only docker image tag" | |
value: ${{ jobs.test.outputs.docker_image_tag }} | |
docker_image: | |
description: "docker image with tag" | |
value: ${{ jobs.test.outputs.docker_image }} | |
pull_request: | |
# NOTE: For develop & master, they are run through helm github action ./build-publish-docker-helm.yml | |
jobs: | |
pre_commit_checks: | |
name: Pre-Commit checks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@main | |
- name: Install poetry | |
run: pipx install poetry | |
- uses: actions/setup-python@main | |
with: | |
cache: 'poetry' | |
- run: poetry install --no-root | |
- uses: pre-commit/action@main | |
test: | |
name: GO Test | |
runs-on: ubuntu-latest | |
outputs: | |
docker_image_name: ${{ steps.prep.outputs.tagged_image_name }} | |
docker_image_tag: ${{ steps.prep.outputs.tag }} | |
docker_image: ${{ steps.prep.outputs.tagged_image }} | |
steps: | |
- uses: actions/checkout@main | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
if: ${{ inputs.push_docker_image }} | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: 🐳 Prepare Docker | |
id: prep | |
env: | |
IMAGE_NAME: ghcr.io/${{ github.repository }} | |
run: | | |
BRANCH_NAME=$(echo $GITHUB_REF_NAME | sed 's|:|-|' | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g' | cut -c1-100 | sed 's/-*$//') | |
# NOTE: `c` is to avoid error by helm if GITHUB_SHA[:7] has only numbers | |
GIT_HASH="c$(echo $GITHUB_SHA | head -c7)" | |
# XXX: Check if there is a slash in the BRANCH_NAME eg: project/add-docker | |
if [[ "$BRANCH_NAME" == *"/"* ]]; then | |
# XXX: Change the docker image package to -alpha | |
IMAGE_NAME="$IMAGE_NAME-alpha" | |
TAG="$(echo "$BRANCH_NAME" | sed 's|/|-|g').$(echo $GIT_HASH)" | |
else | |
TAG="$BRANCH_NAME.$(echo $GIT_HASH)" | |
fi | |
IMAGE_NAME=$(echo $IMAGE_NAME | tr '[:upper:]' '[:lower:]') | |
echo "tagged_image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
echo "tagged_image=${IMAGE_NAME}:${TAG}" >> $GITHUB_OUTPUT | |
echo "::notice::Tagged docker image: ${IMAGE_NAME}:${TAG}" | |
- name: 🐳 Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: 🐳 Build image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
push: false | |
load: true | |
tags: ${{ steps.prep.outputs.tagged_image }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Docker config setup & Pull docker images | |
run: | | |
cp .env-sample .env && | |
docker compose run --rm serve ls | |
- name: 🕮 Validate if there are no pending django migrations. | |
run: | | |
docker compose run --rm serve ./manage.py makemigrations --check --dry-run || { | |
echo 'There are some changes to be reflected in the migration. Make sure to run makemigrations'; | |
exit 1; | |
} | |
- name: 🕮 Validate SentryMonitor config | |
run: | | |
docker compose run --rm serve ./manage.py cron_job_monitor --validate-only || { | |
echo 'There are some changes to be reflected in the SentryMonitor. Make sure to update SentryMonitor'; | |
exit 1; | |
} | |
- name: Run django migrations | |
run: docker compose run --rm serve ./manage.py test --keepdb -v 2 --pattern="test_fake.py" | |
- name: 🤞 Run Test 🧪 | |
run: docker compose run --rm serve pytest --reuse-db --durations=10 | |
- name: 🐳 Docker push | |
if: ${{ inputs.push_docker_image }} | |
run: docker push $IMAGE_TAG | |
env: | |
IMAGE_TAG: ${{ steps.prep.outputs.tagged_image }} | |
validate_helm: | |
name: Validate Helm | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@main | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
- name: 🐳 Helm lint | |
run: helm lint deploy/helm/ifrcgo-helm --values ./deploy/helm/ifrcgo-helm/values-staging.yaml | |
- name: 🐳 Helm template | |
run: helm template deploy/helm/ifrcgo-helm --values ./deploy/helm/ifrcgo-helm/values-staging.yaml |