fix the paragraph bug and onclick search anime item #51
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: CI Workflow | |
on: | |
pull_request: | |
branches: | |
- "**" | |
push: | |
branches: | |
- main | |
jobs: | |
linting-and-formatting: | |
name: Perform linting and formatting checks | |
runs-on: ubuntu-latest | |
outputs: | |
short_commit_hash: ${{ steps.get_commit_hash.outputs.short_commit_hash }} | |
steps: | |
- name: Checkout the Repository | |
uses: actions/checkout@v3 | |
- name: Install Dependencies | |
run: npm install | |
- name: Run linting check | |
run: npm run lint:check | |
- name: Check formatting | |
run: npm run format:check | |
- name: Get Short Commit Hash | |
id: get_commit_hash | |
run: echo "short_commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
build-application: | |
name: Build Application | |
runs-on: ubuntu-latest | |
needs: linting-and-formatting | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.REPO_TOKEN }} | |
- name: Build and Push app.prod Image | |
run: | | |
REPO_NAME_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
docker build -f Dockerfile.app.prod -t ghcr.io/$REPO_NAME_LOWER/app-prod:${{ needs.linting-and-formatting.outputs.short_commit_hash }} . | |
docker push ghcr.io/$REPO_NAME_LOWER/app-prod:${{ needs.linting-and-formatting.outputs.short_commit_hash }} | |
update-infra: | |
name: Update the infra with new Docker images | |
runs-on: ubuntu-latest | |
needs: [linting-and-formatting, build-application] | |
if: github.event_name == 'push' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
- name: Checkout Infra Repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.actor }}/aniweeb_infra | |
token: ${{ secrets.INFRA_REPO_PAT }} | |
path: infra-repo | |
- name: Update Docker Stack and K8s Manifests | |
run: | | |
cd infra-repo | |
REPO_NAME_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
# Update Docker Swarm manifest | |
sed -i "s|image: ghcr.io/.*/app-prod:.*|image: ghcr.io/$REPO_NAME_LOWER/app-prod:${{ needs.linting-and-formatting.outputs.short_commit_hash }}|g" docker/docker-stack.yaml | |
# Update Kubernetes manifest | |
sed -i "s|image: ghcr.io/.*/app-prod:.*|image: ghcr.io/$REPO_NAME_LOWER/app-prod:${{ needs.linting-and-formatting.outputs.short_commit_hash }}|g" k8s/app/deployment.yaml | |
- name: Configure Git | |
run: | | |
cd infra-repo | |
git config user.name "${{ github.actor }}" | |
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | |
- name: Commit and Push Changes | |
run: | | |
cd infra-repo | |
git add docker/docker-stack.yaml k8s/app/deployment.yaml | |
git commit -m "Updated APP Image to ${{ needs.linting-and-formatting.outputs.short_commit_hash }}" | |
git push |