Skip to content

Commit

Permalink
fix: ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Jul 13, 2023
1 parent a9dd3bd commit 4ee3f61
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 58 deletions.
27 changes: 0 additions & 27 deletions .github/task-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,41 +59,14 @@
"placementConstraints": [],
"memory": "100",
"taskRoleArn": "arn:aws:iam::771350349623:role/ECSTaskDefinitionRole",
"compatibilities": [
"EXTERNAL",
"EC2"
],
"taskDefinitionArn": "arn:aws:ecs:eu-west-1:771350349623:task-definition/vite-template:2",
"family": "vite-template",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.private-registry-authentication.secretsmanager"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
}
],
"pidMode": null,
"requiresCompatibilities": [
"EC2"
],
"networkMode": "bridge",
"runtimePlatform": null,
"cpu": null,
"revision": 2,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
Expand Down
75 changes: 44 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ on:

env:
NODE_VERSION: 18.13.0
APP_BUILD_ARGS: --unlock-robots
APP_BUILD_PATH: ./build
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/web
ECS_TASK_DEFINITION: ${{ github.workspace }}/.github/task-definition.json
DOCKER_FILE: node_modules/@lomray/vite-ssr-boost/workflow/Dockerfile
ECS_TASK_DEFINITION: .github/task-definition.json
ECS_TASK_CONTAINER_NAME: web
ECS_SERVICE: vite-template
ECS_CLUSTER: Development
Expand Down Expand Up @@ -45,7 +48,7 @@ jobs:
- name: Build application
run: |
npm pkg delete scripts.prepare
npm run build -- --unlock-robots
npm run build -- ${{ env.APP_BUILD_ARGS }}
- name: Create release asset
run: zip -r build.zip build package.json package-lock.json README.md
Expand All @@ -64,11 +67,42 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: dockerfile-artifact
path: node_modules/@lomray/vite-ssr-boost/workflow/Dockerfile
path: ${{ env.DOCKER_FILE }}

docker-build:
- name: Archive AWS task definition
uses: actions/upload-artifact@v3
with:
name: aws-task-definition-artifact
path: ${{ env.ECS_TASK_DEFINITION }}

release:
needs: [build]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-release
cancel-in-progress: true
outputs:
version: ${{ steps.package-version.outputs.version }}

steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: build-artifact

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release

- name: Get version
id: package-version
run: npx @lomray/microservices-cli package-version

docker-build:
needs: [build, release]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-build-docker
cancel-in-progress: true
Expand All @@ -85,10 +119,6 @@ jobs:
with:
name: dockerfile-artifact

- name: Get version
id: package-version
run: npx @lomray/microservices-cli package-version

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -105,7 +135,7 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,prefix={{branch}}-,value=${{ steps.package-version.outputs.version }}
type=raw,prefix={{branch}}-,value=${{ needs.release.outputs.version }}
type=raw,prefix=latest-,value={{branch}}
- name: Build and push Docker image
Expand All @@ -119,7 +149,7 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_PATH=./build
BUILD_PATH=${{ env.APP_BUILD_PATH }}
deploy:
needs: [ docker-build ]
Expand All @@ -129,7 +159,9 @@ jobs:
cancel-in-progress: true

steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: aws-task-definition-artifact

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
Expand All @@ -142,7 +174,7 @@ jobs:
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
task-definition: task-definition.json
container-name: ${{ env.ECS_TASK_CONTAINER_NAME }}
image: ${{ needs.docker-build.outputs.image-tag }}

Expand All @@ -152,22 +184,3 @@ jobs:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}

release:
needs: [build, docker-build]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-build-docker
cancel-in-progress: true

steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: build-artifact

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release

0 comments on commit 4ee3f61

Please sign in to comment.