Skip to content
Merged
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
68 changes: 38 additions & 30 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
REPOSITORY_NAME: ${{ github.event.repository.name }}
ECR_REPOSITORY: codio/${{ github.event.repository.name }}

permissions:
contents: read
id-token: write

jobs:
api-test:
name: "API 📡 - test 🧪"
runs-on: ubuntu-latest
if: false # disable because repo have modificatons
env:
RAILS_ENV: test
TEST_DATABASE_URL: mysql2://root:dolos@127.0.0.1:3306/dolos_test
Expand Down Expand Up @@ -355,10 +365,10 @@ jobs:
fail-fast: false
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup Node 📚
uses: actions/setup-node@v3
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}

Expand Down Expand Up @@ -397,44 +407,42 @@ jobs:
cd cli/
yarn build --force

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.ECR_UPLOADER_KEY }}
aws-secret-access-key: ${{ secrets.ECR_UPLOADER_SECRET }}
aws-region: us-east-1

- name: Get Current Branch
id: get-branch
uses: codio/get-branch-name-github-action@v1

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@main
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::878986216776:role/Github/GithubECRUploadRole_${{ env.REPOSITORY_NAME }}
role-session-name: GithubAction

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
uses: aws-actions/amazon-ecr-login@v2

- name: app Docker build
run: docker build -t tmp_app_img --file ./docker-codio/Dockerfile .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: push app image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: codio/dolos
IMAGE_TAG: ${{ github.sha }}
BRANCH: ${{ steps.get-branch.outputs.branch }}
- name: Create and use a new builder instance
run: |
docker tag tmp_app_img $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag tmp_app_img $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH
docker buildx create --name ga-builder --use

- name: push image to Amazon ECR
uses: docker/build-push-action@v5
timeout-minutes: 20
with:
context: .
file: ./docker-codio/Dockerfile
push: true
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ steps.get-branch.outputs.branch }}
builder: ga-builder
cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:cache
cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:cache

- name: push app dev version
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: codio/dolos
run: |
docker tag tmp_app_img $ECR_REGISTRY/$ECR_REPOSITORY:dev
docker push $ECR_REGISTRY/$ECR_REPOSITORY:dev
if: ${{ steps.get-branch.outputs.branch == 'master' }}

- name: Logout of Amazon ECR
if: always()
Expand Down
Loading