Merge pull request #321 from ugahacks/feature/deployment-test #238
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: Release Branch CI/CD | |
on: | |
push: | |
branches: | |
- "release" | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
REGION: us-central1 | |
DEPLOY_ENV: stage | |
CI: true # silences "yarn install" | |
jobs: | |
flake8: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Lint Python Code | |
run: python -V | |
pytest: | |
needs: flake8 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Test Python Code | |
run: echo "PYTHON UNIT TESTING COMPLETE" | |
jest: | |
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, 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 X | |
- name: Build and Push ugahacks-x Container | |
run: |- | |
echo "ugahacks-x changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/ugahacks-x-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/ugahacks-x | |
docker push gcr.io/${{ env.PROJECT_ID }}/ugahacks-x-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-x') | |
- name: Deploy ugahacks-x to Cloud Run | |
id: deploy_ugahacks_x | |
uses: google-github-actions/deploy-cloudrun@v1 | |
with: | |
service: ugahacks-x-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/ugahacks-x-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-x') | |
- name: ugahacks-x Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_ugahacks_x.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'ugahacks-x') | |
# 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/deploy-cloudrun@v1 | |
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') | |
# 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') | |
# 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') | |
# 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') | |
# Makeathon 3 | |
- name: Build and Push makeathon-3 Container | |
run: |- | |
echo "makeathon-3 changed, building ..." | |
docker build -t gcr.io/${{ env.PROJECT_ID }}/makeathon-3-${{ env.DEPLOY_ENV }}:${{ github.sha }} web/makeathon-3 | |
docker push gcr.io/${{ env.PROJECT_ID }}/makeathon-3-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-3') | |
- name: Deploy makeathon-3 to Cloud Run | |
id: deploy_makeathon_3 | |
uses: google-github-actions/[email protected] | |
with: | |
service: makeathon-3-${{ env.DEPLOY_ENV }} | |
image: gcr.io/${{ env.PROJECT_ID }}/makeathon-3-${{ env.DEPLOY_ENV }}:${{ github.sha }} | |
region: ${{ env.REGION }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-3') | |
- name: makeathon-3 Post Deployment | |
run: |- | |
echo "Active URL:" | |
echo ${{ steps.deploy_makeathon_2.outputs.url }} | |
if: contains(steps.file_changes.outputs.files , 'makeathon-3') |