v1.4.12 #365
Workflow file for this run
This file contains hidden or 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
| on: | |
| push: | |
| release: | |
| types: [published] | |
| name: Docker Build and Push | |
| env: | |
| ECR_REGISTRY: 151345152001.dkr.ecr.ap-northeast-2.amazonaws.com | |
| ECR_REPOSITORY: popo-admin-web | |
| jobs: | |
| lint: | |
| name: Run pre-commit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install pre-commit | |
| run: | | |
| pip install pre-commit | |
| - name: Install dependencies | |
| run: npm ci --force | |
| - name: Run pre-commit | |
| run: | | |
| pre-commit run --all-files | |
| docker_build_and_push: | |
| name: Docker build and push | |
| needs: lint | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: 'arm64' # support AWS EC2 t4g | |
| - 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: ap-northeast-2 | |
| - name: Login to Amazon ECR | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Determine Prod/Dev Stage | |
| run: | | |
| if [[ ${{ github.event_name }} == 'release' ]]; then | |
| echo "PROD" | |
| echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
| echo "NEXT_PUBLIC_ENV=prod" >> $GITHUB_ENV | |
| else | |
| echo "DEV" | |
| echo "IMAGE_TAG=latest" >> $GITHUB_ENV | |
| echo "NEXT_PUBLIC_ENV=dev" >> $GITHUB_ENV | |
| fi | |
| - name: Build and Push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/arm64 # support AWS EC2 t4g | |
| tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} | |
| build-args: | | |
| "NEXT_PUBLIC_ENV=${{ env.NEXT_PUBLIC_ENV }}" | |
| "POPO_VERSION=${{ github.event.release.tag_name || github.sha }}" | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| push: true | |
| provenance: false # Disable image index metadata | |
| redeploy_dev_service: | |
| name: Redeploy Dev Service | |
| needs: docker_build_and_push | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Redeploy Dev Service | |
| run: | | |
| RESPONSE=$(curl -s -o response.txt -w "%{http_code}" -X POST ${{ secrets.PORTAINER_DEV_SERVICE_WEBHOOK }}) | |
| if [ "$RESPONSE" -ne 204 ]; then | |
| echo "❌ Deployment failed! HTTP Response: $RESPONSE" | |
| cat response.txt # 오류 메시지 출력 (필요 시) | |
| exit 1 | |
| fi | |
| echo "✅ Deployment successful! HTTP Response: $RESPONSE" | |
| deploy_health_check: | |
| name: Check Application Status | |
| needs: redeploy_dev_service | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check the deployed service URL | |
| uses: jtalk/url-health-check-action@v4 | |
| with: | |
| url: https://admin.popo.poapper.club|https://admin.popo-dev.poapper.club | |
| follow-redirect: true | |
| max-attempts: 3 | |
| retry-delay: 10s |