Merge pull request #264 from ugahacks/release #93
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: Master Branch CI/CD | |
on: | |
push: | |
branches: | |
- "master" | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
REGION: us-central1 | |
DEPLOY_ENV: prod | |
CI: true # silences "yarn install" | |
jobs: | |
flake8: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Lint Python Code | |
run: python -V | |
eslint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Update Yarn | |
run: yarn set version latest | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Cache | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
cache: "yarn" | |
- name: Install project dependencies | |
run: yarn install | |
- name: Lint | |
run: | | |
echo "yarn version: $(yarn --version)" | |
yarn workspaces foreach run lint | |
pytest: | |
needs: flake8 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Test Python Code | |
run: echo "PYTHON UNIT TESTING COMPLETE" | |
jest: | |
needs: eslint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Test Typescript Code | |
run: echo "TYPESCRIPT UNIT TESTING COMPLETE" | |
# Conditionally build, containerize, and deploy UGAHacks services iff files are changed # | |
deploy: | |
needs: [flake8, eslint, pytest, jest] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
project_id: ${{ env.PROJECT_ID }} | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
export_default_credentials: true # Set to true to authenticate the Cloud Run action | |
- name: Authorize Docker push | |
run: gcloud auth configure-docker | |
- id: file_changes | |
name: Get Changed Files | |
uses: trilom/[email protected] | |
with: | |
output: "," | |
fileOutput: "," | |
- name: Output Changed Files | |
run: | | |
echo "Changed Files (~/files.csv):" | |
cat $HOME/files.csv | |
# UGAHacks 9 | |
- name: Build and Push ugahacks-9 Container | |
run: |- | |
echo "ugahacks-9 changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/ugahacks-9-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/ugahacks-9 | |
docker push gcr.io/${{ env.PROJECT_ID }}/ugahacks-9-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-9') | |
- name: Deploy ugahacks-9 to Cloud Run | |
id: deploy_ugahacks_9 | |
uses: google-github-actions/[email protected] | |
with: | |
service: ugahacks-9-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/ugahacks-9-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-9') | |
- name: ugahacks-9 Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_ugahacks_9.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-9') | |
# UGAHacks 8 | |
- name: Build and Push ugahacks-8 Container | |
run: |- | |
echo "ugahacks-8 changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/ugahacks-8-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/ugahacks-8 | |
docker push gcr.io/${{ env.PROJECT_ID }}/ugahacks-8-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-8') | |
- name: Deploy ugahacks-8 to Cloud Run | |
id: deploy_ugahacks_8 | |
uses: google-github-actions/[email protected] | |
with: | |
service: ugahacks-8-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/ugahacks-8-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-8') | |
- name: ugahacks-8 Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_ugahacks_8.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-8') | |
# Hacks 8 Makeathon | |
- name: Build and Push makeathon-8 Container | |
run: |- | |
echo "makeathon-8 changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/makeathon-8-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/makeathon-8 | |
docker push gcr.io/${{ env.PROJECT_ID }}/makeathon-8-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-8') | |
- name: Deploy makeathon-8 to Cloud Run | |
id: deploy_makeathon_8 | |
uses: google-github-actions/[email protected] | |
with: | |
service: makeathon-8-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/makeathon-8-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-8') | |
- name: makeathon-8 Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_makeathon_8.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-8') | |
# UGAHacks 7 | |
- name: Build and Push ugahacks-7 Container | |
run: |- | |
echo "ugahacks-7 changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/ugahacks-7-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/ugahacks-7 | |
docker push gcr.io/${{ env.PROJECT_ID }}/ugahacks-7-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-7') | |
- name: Deploy ugahacks-7 to Cloud Run | |
id: deploy_ugahacks_7 | |
uses: google-github-actions/[email protected] | |
with: | |
service: ugahacks-7-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/ugahacks-7-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-7') | |
- name: ugahacks-7 Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_ugahacks_7.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-7') | |
# UGAHacks 6 | |
- name: Build and Push ugahacks-6 Container | |
run: |- | |
echo "ugahacks-6 changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/ugahacks-6-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/ugahacks-6 | |
docker push gcr.io/${{ env.PROJECT_ID }}/ugahacks-6-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-6') | |
- name: Deploy ugahacks-6 to Cloud Run | |
id: deploy_ugahacks_6 | |
uses: google-github-actions/[email protected] | |
with: | |
service: ugahacks-6-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/ugahacks-6-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-6') | |
- name: ugahacks-6 Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_ugahacks_6.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-6') | |
# UGAHacks Org | |
- name: Build and Push ugahacks-org Container | |
run: |- | |
echo "ugahacks-org changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/ugahacks-org-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/ugahacks-org | |
docker push gcr.io/${{ env.PROJECT_ID }}/ugahacks-org-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-org') | |
- name: Deploy ugahacks-org to Cloud Run | |
id: deploy_ugahacks_org | |
uses: google-github-actions/[email protected] | |
with: | |
service: ugahacks-org-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/ugahacks-org-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-org') | |
- name: ugahacks-org Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_ugahacks_org.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-org') | |
# my.ugahacks | |
- name: Build and Push myugahacks Container | |
run: |- | |
echo "myugahacks changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/myugahacks-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/myugahacks | |
docker push gcr.io/${{ env.PROJECT_ID }}/myugahacks-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'myugahacks') | |
- name: Deploy myugahacks to Cloud Run | |
id: deploy_myugahacks | |
uses: google-github-actions/[email protected] | |
with: | |
service: myugahacks-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/myugahacks-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'myugahacks') | |
- name: myugahacks Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_myugahacks.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'myugahacks') | |
# Makeathon 2 | |
- name: Build and Push makeathon-2 Container | |
run: |- | |
echo "makeathon-2 changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/makeathon-2-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/makeathon-2 | |
docker push gcr.io/${{ env.PROJECT_ID }}/makeathon-2-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-2') | |
- name: Deploy makeathon-2 to Cloud Run | |
id: deploy_makeathon_2 | |
uses: google-github-actions/[email protected] | |
with: | |
service: makeathon-2-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/makeathon-2-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-2') | |
- name: makeathon-2 Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_makeathon_2.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-2') |