-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
639 additions
and
167 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: "Backend" | ||
|
||
on: | ||
push: | ||
branches: [master, next, feat/yrs-signalling-reloaded] | ||
paths: | ||
- 'backend/**' | ||
pull_request: | ||
branches: [master, next] | ||
paths: | ||
- 'backend/**' | ||
|
||
jobs: | ||
build: | ||
name: "🧦 Build" | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: backend/signaling | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Build and export | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: backend/signaling | ||
tags: signaling:latest | ||
outputs: type=docker,dest=/tmp/signaling.tar | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: signaling | ||
path: /tmp/signaling.tar | ||
|
||
infrastructure: | ||
needs: | ||
- build | ||
uses: ./.github/workflows/infrastructure.yml | ||
secrets: inherit | ||
|
||
deploy: | ||
name: "🏃♂️ Deploy" | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
needs: | ||
- build | ||
- infrastructure | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
steps: | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-region: us-east-1 | ||
role-to-assume: ${{ needs.infrastructure.outputs.deploy_role }} | ||
role-session-name: DeploySession | ||
- name: Login to Amazon ECR | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
- name: Download artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: signaling | ||
path: /tmp | ||
- name: Tag and upload image to ECR | ||
env: | ||
ECR_REPOSITORY: ${{ needs.infrastructure.outputs.signaling_ecr_url }} | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker load --input /tmp/signaling.tar | ||
docker tag signaling:latest $ECR_REPOSITORY:$IMAGE_TAG | ||
docker tag signaling:latest $ECR_REPOSITORY:latest | ||
docker push $ECR_REPOSITORY --all-tags | ||
- name: Deploy image to EC2 | ||
run: | | ||
aws ssm send-command \ | ||
--document-name "sobaka-signaling-sobaka-next-deploy" \ | ||
--instance-id "${{ needs.infrastructure.outputs.instance_id }}" | ||
concurrency: | ||
group: "${{ github.ref }}-backend" | ||
cancel-in-progress: true |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: "Frontend" | ||
|
||
on: | ||
push: | ||
branches: [master, next, feat/yrs-signalling-reloaded] | ||
paths: | ||
- 'frontend/**' | ||
- 'sobaka-dsp/**' | ||
pull_request: | ||
branches: [master, next] | ||
paths: | ||
- 'frontend/**' | ||
- 'sobaka-dsp/**' | ||
|
||
jobs: | ||
build: | ||
name: "🧦 Build" | ||
runs-on: macos-latest | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install latest nightly | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
components: rust-src | ||
target: wasm32-unknown-unknown | ||
override: true | ||
# Cache somehow breaks wasm_opt | ||
# https://github.com/Marcel-G/xtask-wasm/blob/main/src/wasm_opt.rs#L38 | ||
# - uses: Swatinem/rust-cache@v2 | ||
# with: | ||
# workspaces: sobaka-dsp | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.14 | ||
cache: 'npm' | ||
cache-dependency-path: '**/package-lock.json' | ||
- run: npm ci | ||
- run: npm run build | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: frontend-build-output | ||
path: frontend/build | ||
|
||
infrastructure: | ||
needs: | ||
- build | ||
uses: ./.github/workflows/infrastructure.yml | ||
secrets: inherit | ||
|
||
deploy: | ||
name: "🏃♂️ Deploy" | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
needs: | ||
- infrastructure | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
steps: | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-region: us-east-1 | ||
role-to-assume: ${{ needs.infrastructure.outputs.deploy_role }} | ||
role-session-name: DeploySession | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: frontend-build-output | ||
path: frontend/build | ||
- name: "Deploy files to S3" | ||
run: | | ||
aws s3 sync frontend/build s3://${{ needs.infrastructure.outputs.deploy_bucket }} \ | ||
--metadata-directive REPLACE \ | ||
--cache-control 'max-age=31104000' | ||
aws s3 cp frontend/build/index.html s3://${{ needs.infrastructure.outputs.deploy_bucket }} \ | ||
--metadata-directive REPLACE \ | ||
--cache-control 'max-age=3600' | ||
- name: "Invalidate CloudFront Cache" | ||
run: | | ||
aws cloudfront create-invalidation \ | ||
--distribution-id ${{ needs.infrastructure.outputs.cdn_distribution_id }} \ | ||
--paths "/index.html" | ||
concurrency: | ||
group: "${{ github.ref }}-frontend" | ||
cancel-in-progress: true |
Oops, something went wrong.