move to production #2485
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: website-code-tests | |
on: | |
pull_request: | |
branches: | |
- main | |
- staging | |
- master | |
jobs: | |
check: | |
name: check for changes in Website | |
outputs: | |
run_website_tests: ${{ steps.check_files.outputs.run_website_tests }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: check modified website folder | |
id: check_files | |
run: | | |
echo "=============== list modified files ===============" | |
git diff --name-only HEAD^ HEAD | |
echo "========== check paths of modified files ==========" | |
git diff --name-only HEAD^ HEAD > files.txt | |
echo "run_website_tests=false" >>$GITHUB_OUTPUT | |
while IFS= read -r file | |
do | |
echo $file | |
if [[ $file == website/* ]]; then | |
echo "run_website_tests=true" >>$GITHUB_OUTPUT | |
fi | |
done < files.txt | |
drive: | |
name: website code tests | |
needs: [check] | |
if: needs.check.outputs.run_website_tests == 'true' | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: website | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Google login | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: "${{ secrets.GCP_FRONTEND_PROJECT_SA_CREDENTIALS }}" | |
- name: Setup Cloud SDK(gcloud) | |
uses: "google-github-actions/setup-gcloud@v1" | |
- name: Create google_application_credentials.json file | |
id: create-google-application-credentials-file | |
uses: jsdaniell/[email protected] | |
with: | |
name: "google_application_credentials.json" | |
json: ${{ secrets.GCP_FRONTEND_PROJECT_SA_CREDENTIALS }} | |
dir: "website/" | |
- name: Create app.yaml and .env.yaml files | |
run: | | |
echo "========== Creating app.yaml file ==========" | |
echo "runtime: python" > app.yaml | |
echo "env: flex" >> app.yaml | |
echo "service: staging" >> app.yaml | |
echo "includes:" >> app.yaml | |
echo " - .env.yaml" >> app.yaml | |
echo "========== Creating .env.yaml file ==========" | |
echo "env_variables:" > .env.yaml | |
echo " SECRET: ${{ secrets.WEBSITE_SECRET }}" >> .env.yaml | |
echo " CLOUDINARY_KEY: ${{ secrets.WEBSITE_CLOUDINARY_KEY }}" >> .env.yaml | |
echo " CLOUDINARY_NAME: ${{ secrets.WEBSITE_CLOUDINARY_NAME }}" >> .env.yaml | |
echo " CLOUDINARY_SECRET: ${{ secrets.WEBSITE_CLOUDINARY_SECRET }}" >> .env.yaml | |
echo " DATABASE_URI: ${{ secrets.WEBSITE_STAGE_DATABASE_URI }}" >> .env.yaml | |
echo " GS_BUCKET_NAME: ${{ secrets.WEBSITE_STAGE_GS_BUCKET_NAME }}" >> .env.yaml | |
echo " REACT_WEB_STATIC_HOST: ${{ secrets.WEBSITE_STAGE_REACT_WEB_STATIC_HOST }}" >> .env.yaml | |
echo " SECRET_KEY: ${{ secrets.WEBSITE_STAGE_SECRET_KEY }}" >> .env.yaml | |
echo " DJANGO_ALLOWED_HOSTS: ${{ secrets.WEBSITE_DJANGO_ALLOWED_HOSTS }}" >> .env.yaml | |
echo " DEBUG: False" >> .env.yaml | |
echo " GOOGLE_APPLICATION_CREDENTIALS: /app/google_application_credentials.json" >> .env.yaml | |
- name: Node setup | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: Install requirements | |
run: npm install | |
- name: Run tests and collect coverage | |
run: npm test -- --coverage | |
continue-on-error: true | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |