Merge branch 'develop' of https://github.com/OpenWallet-2025/OpenWall… #6
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
| name: ai-ci-workflows | |
| on: | |
| push: | |
| branches: [develop] | |
| pull_request: | |
| branches: [develop] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| packages: write | |
| issues: write # [추가] 이슈 생성을 위해 쓰기 권한 필요 | |
| jobs: | |
| # [1단계] 테스트 Job: PR 및 Push 모든 상황에서 실행됨 | |
| code-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Code Test End Up | |
| run: echo "code test end up successfully!" | |
| # [2단계-A] 태그 생성: Push 및 PR 모두에서 실행 (조건 제거됨) | |
| push-changes: | |
| runs-on: ubuntu-latest | |
| needs: code-test | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Tag Commit as Verified | |
| run: | | |
| echo "push test verified commit" | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| TAG_NAME="verified-${GITHUB_SHA::7}" | |
| # 태그가 이미 존재할 경우를 대비해 강제 업데이트(-f)하거나 체크 | |
| git tag -f $TAG_NAME | |
| git push origin $TAG_NAME -f | |
| echo "Tagged commit as $TAG_NAME" | |
| # [2단계-B] 도커 빌드: Push 및 PR 모두에서 실행 | |
| docker-build-and-push: | |
| runs-on: ubuntu-latest | |
| needs: code-test | |
| outputs: | |
| image_tag: ${{ steps.set-vars.outputs.sha_short }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set variables | |
| id: set-vars | |
| run: | | |
| echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT | |
| echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build & Push Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: ghcr.io/${{ steps.set-vars.outputs.owner }}/ai:${{ steps.set-vars.outputs.sha_short }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build Succeed Message | |
| run: echo "succeed to build and push docker image" | |
| # [3단계] Manifest 업데이트: 여전히 Push 이벤트일 때만 하는 것이 안전함 | |
| update-manifest-repo: | |
| runs-on: ubuntu-latest | |
| needs: docker-build-and-push | |
| steps: | |
| - name: Determine branch | |
| id: branch | |
| run: echo "branch=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT | |
| - name: Checkout Manifests Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.repository_owner }}/OpenWallet-manifests | |
| token: ${{ secrets.MANIFEST_ACCESS }} | |
| ref: ${{ steps.branch.outputs.branch }} | |
| - name: Update Image Tag | |
| run: | | |
| NEW_TAG="${{ needs.docker-build-and-push.outputs.image_tag }}" | |
| echo "Updating tag to: $NEW_TAG" | |
| sed -i '/repository:[[:space:]]*ghcr\.io\/openwallet-2025\/ai/{n;s/^[[:space:]]*tag:.*/ tag: "'"${NEW_TAG}"'"/}' apps/ai/values.yaml | |
| - name: Commit & Push | |
| run: | | |
| git config user.name "${{ github.actor }}" | |
| git config user.email "${{ github.actor }}@users.noreply.github.com" | |
| git add . | |
| git commit -m "Update image to ${{ needs.docker-build-and-push.outputs.image_tag }}" || echo "No changes to commit" | |
| git push origin ${{ steps.branch.outputs.branch }} | |
| echo "Commit And Push Complete. Actor: ${{ github.actor }}" |