This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
Merge pull request #44 from ar-io/update-promise-cache #224
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: Node.js CI | |
on: [push] | |
jobs: | |
node_version: | |
runs-on: ubuntu-latest | |
outputs: | |
NODE_VERSION: ${{ steps.node_version.outputs.NODE_VERSION }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Read .nvmrc | |
id: node_version | |
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc |cut -c2-8) | |
build: | |
needs: [node_version] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
step: ['lint:check', 'format:check', 'build'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Read .nvmrc | |
id: node_version | |
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc |cut -c2-8) | |
- name: Use Node.js ${{ needs.node_version.outputs.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ needs.node_version.outputs.NODE_VERSION }} | |
# Build Typescript | |
- run: yarn --immutable --immutable-cache | |
- run: yarn | |
- run: yarn ${{ matrix.step }} | |
test: | |
runs-on: ubuntu-latest | |
needs: [node_version, build] | |
steps: | |
- uses: actions/checkout@v3 | |
- run: yarn docker:integration | |
push: | |
needs: [node_version, build, test] | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
checks: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
# Build and push container image to GCR (only on main branch) | |
- name: Log in to the GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push container image to GitHub Container Registry | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
build-args: | | |
NODE_VERSION=${{ needs.node_version.outputs.NODE_VERSION }} | |
tags: | | |
ghcr.io/ar-io/arns-service:latest | |
ghcr.io/ar-io/arns-service:${{ github.sha }} | |
# Deploy | |
deploy: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: [build, test, push] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ secrets.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }} | |
role-skip-session-tagging: true | |
role-to-assume: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/DeploymentRole | |
role-external-id: arn:aws:iam::${{ secrets.ACCOUNT_ID }}:role/DeploymentRole | |
role-duration-seconds: 900 | |
- name: Update Deployed image | |
run: | | |
aws ecs update-service --cluster ${{ secrets.AWS_CLUSTER }} --service ${{ secrets.AWS_SERVICE }} --force-new-deployment --region ${{ secrets.AWS_REGION }} |