Merge pull request #29 from DataSeer/automatic_docker_build #11
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: Build and Deploy (Dev) | |
on: | |
push: | |
branches: | |
- dev | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Copy default config files | |
run: for file in conf/*.json.default; do cp "$file" "${file%.default}"; done | |
- name: Run ESLint | |
run: npm run lint | |
build: | |
needs: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Log in to AWS ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Extract repository name and short commit ID | |
id: extract_repo | |
run: | | |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F '/' '{print $2}' | tr '[:upper:]' '[:lower:]') | |
SHORT_COMMIT_ID=$(echo "${{ github.sha }}" | cut -c1-7) | |
echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT | |
echo "short_commit_id=${SHORT_COMMIT_ID}" >> $GITHUB_OUTPUT | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: | | |
${{ steps.login-ecr.outputs.registry }}/${{ steps.extract_repo.outputs.repo_name }}:dev-${{ steps.extract_repo.outputs.short_commit_id }} | |
${{ steps.login-ecr.outputs.registry }}/${{ steps.extract_repo.outputs.repo_name }}:dev-latest |