Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy action bundled into CI workflow #950

Merged
merged 7 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,23 @@ jobs:
- run: npm run build
- run: npm run e2e

lighthouse-report:
required-checks:
needs: [lint, unit-test, e2e-test]
runs-on: ubuntu-latest
steps:
- run: exit 0

deploy:
needs: required-checks
uses: ./.github/workflows/deploy.yml
secrets: inherit

lighthouse-report:
needs: required-checks
uses: ./.github/workflows/lighthouse-report.yml
secrets: inherit

size-report:
needs: [lint, unit-test, e2e-test]
needs: required-checks
uses: ./.github/workflows/size-report.yml
secrets: inherit
51 changes: 0 additions & 51 deletions .github/workflows/deploy-master.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
name: Deploy Branch
name: Deploy

on:
workflow_dispatch: ~
pull_request:
types: [ opened, synchronize, reopened ]
workflow_call: ~

jobs:
deploy:

runs-on: ubuntu-latest

env:
IMAGE_NAME: eu.gcr.io/${{ secrets.GCP_PROJECT_ID }}/turnilo
REF_NAME: ${{ github.head_ref }}

# disable for branches from forks
if: github.repository == 'allegro/turnilo'

env:
IMAGE_NAME: eu.gcr.io/${{ secrets.GCP_PROJECT_ID }}/turnilo
TAG_NAME: ${{ github.head_ref || 'latest' }}

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Authenticate on GCP
uses: google-github-actions/setup-gcloud@v0
Expand All @@ -32,15 +30,15 @@ jobs:
run: gcloud auth configure-docker --quiet

- name: Build Docker image
run: docker build . -t $IMAGE_NAME:${REF_NAME//[^a-z0-9]/-}
run: docker build . -t $IMAGE_NAME:${TAG_NAME//[^a-z0-9]/-}

- name: Push Docker image
run: docker push $IMAGE_NAME:${REF_NAME//[^a-z0-9]/-}
run: docker push $IMAGE_NAME:${TAG_NAME//[^a-z0-9]/-}

- name: Deploy app
run: |
gcloud run deploy turnilo-${REF_NAME//[^a-z0-9]/-} \
--image $IMAGE_NAME:${REF_NAME//[^a-z0-9]/-} \
gcloud run deploy turnilo-${TAG_NAME//[^a-z0-9]/-} \
--image $IMAGE_NAME:${TAG_NAME//[^a-z0-9]/-} \
--region europe-west1 \
--platform managed \
--allow-unauthenticated \
Expand All @@ -51,11 +49,13 @@ jobs:


- name: Get app URL
if: ${{ github.head_ref }}
id: app-url
run: |
echo ::set-output name=app_url::$(gcloud run services describe turnilo-${REF_NAME//[^a-z0-9]/-} --region europe-west1 --format 'value(status.url)')
echo ::set-output name=app_url::$(gcloud run services describe turnilo-${TAG_NAME//[^a-z0-9]/-} --region europe-west1 --format 'value(status.url)')

- name: Print app URL
if: ${{ github.head_ref }}
uses: actions/github-script@v6
env:
APP_URL: ${{ steps.app-url.outputs.app_url }}
Expand All @@ -70,5 +70,5 @@ jobs:

- name: Delete previous Docker image(s)
run: |
gcloud container images list-tags $IMAGE_NAME:$REF_NAME --filter='-tags:*' --format='get(digest)' --limit=unlimited | \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you removed ref_name but at line 56 (and few before) you changed it to tag_name- is it a typo or it should be like that?

gcloud container images list-tags $IMAGE_NAME --filter='-tags:*' --format='get(digest)' --limit=unlimited | \
xargs -I {digest} gcloud container images delete "$IMAGE_NAME@{digest}" --quiet
3 changes: 2 additions & 1 deletion .github/workflows/lighthouse-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ on:

jobs:
lighthouse-report:

runs-on: ubuntu-latest

if: github.event_name == 'pull_request'

# add permission to comment PR created by dependantbot
permissions:
issues: write
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/size-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ on:
jobs:
size-report:
runs-on: ubuntu-latest
env:
CI_JOB_NUMBER: 1

if: github.event_name == 'pull_request'

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ on:

jobs:
undeploy:

runs-on: ubuntu-latest

# disable for branches from forks
if: github.repository == 'allegro/turnilo'

env:
IMAGE_NAME: eu.gcr.io/${{ secrets.GCP_PROJECT_ID }}/turnilo
REF_NAME: ${{ github.head_ref }}

# disable for branches from forks
if: github.repository == 'allegro/turnilo'

steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down