refactor: make secrets configurable #92
Workflow file for this run
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: "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 |