|
| 1 | +name: Push image build by pnpm 16g |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + project: |
| 7 | + description: 'the name of project to be built and the corresponding image' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | + outputs: |
| 12 | + tag: |
| 13 | + value: ${{ jobs.build.outputs.tag }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + environment: azure-dev-east-us |
| 19 | + env: |
| 20 | + BUF_TOKEN: ${{ secrets.BUF_TOKEN }} |
| 21 | + BUF_BUILD_TOKEN: ${{ secrets.BUF_BUILD_TOKEN }} |
| 22 | + GH_PACKAGES_ORG_TOKEN: ${{ secrets.GH_PACKAGES_ORG_TOKEN }} |
| 23 | + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 24 | + outputs: |
| 25 | + tag: ${{ steps.build-and-push.outputs.TAG }} |
| 26 | + steps: |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v3 |
| 29 | + - name: Setup pnpm |
| 30 | + uses: pnpm/action-setup@v2 |
| 31 | + with: |
| 32 | + version: 8 |
| 33 | + - name: Setup Node env |
| 34 | + uses: actions/setup-node@v3 |
| 35 | + with: |
| 36 | + node-version: 18 |
| 37 | + cache: 'pnpm' |
| 38 | + - name: Install Dependencies |
| 39 | + run: pnpm install |
| 40 | + - name: Build |
| 41 | + run: pnpm run build |
| 42 | + |
| 43 | + - name: Set up CD tools |
| 44 | + uses: coscene-io/setup-cd-tools@v2.0.1 |
| 45 | + env: |
| 46 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: "true" |
| 47 | + with: |
| 48 | + skaffold: '2.3.1' |
| 49 | + - name: ACR login |
| 50 | + uses: docker/login-action@v2 |
| 51 | + with: |
| 52 | + registry: coseus.azurecr.io |
| 53 | + username: ${{ secrets.ACR_ADMIN_USERNAME }} |
| 54 | + password: ${{ secrets.ACR_ADMIN_PASSWORD }} |
| 55 | + - name: Set up buf netrc |
| 56 | + uses: extractions/netrc@v1 |
| 57 | + with: |
| 58 | + machine: buf.build |
| 59 | + username: ${{ secrets.BUF_USERNAME }} |
| 60 | + password: ${{ secrets.BUF_TOKEN }} |
| 61 | + - name: Set up github netrc |
| 62 | + uses: extractions/netrc@v1 |
| 63 | + with: |
| 64 | + machine: github.com |
| 65 | + username: ${{ secrets.GH_PACKAGES_ORG_USERNAME }} |
| 66 | + password: ${{ secrets.GH_PACKAGES_ORG_TOKEN }} |
| 67 | + - name: Set up Docker Buildx |
| 68 | + uses: docker/setup-buildx-action@v2 |
| 69 | + - name: Docker build & push |
| 70 | + id: build-and-push |
| 71 | + run: | |
| 72 | + result=$(skaffold build --build-concurrency=0 -q | jq '.builds[0].tag') |
| 73 | + skaffold build --build-concurrency=0 -t latest |
| 74 | + echo $result |
| 75 | + withoutRegistry=${result#*:} |
| 76 | + echo $withoutRegistry |
| 77 | + withoutDigest=${withoutRegistry%@*} |
| 78 | + echo $withoutDigest |
| 79 | + echo "TAG=${withoutDigest}" >> $GITHUB_OUTPUT |
| 80 | +
|
| 81 | + cp-image-to-aliyun: |
| 82 | + needs: |
| 83 | + - build |
| 84 | + uses: coscene-io/cicd-templates/.github/workflows/cp-image-to-aliyun.yml@main |
| 85 | + with: |
| 86 | + project: ${{ inputs.project }} |
| 87 | + tag: ${{ needs.build.outputs.tag }} |
| 88 | + secrets: inherit |
| 89 | + |
| 90 | + callout: |
| 91 | + needs: |
| 92 | + - build |
| 93 | + uses: coscene-io/cicd-templates/.github/workflows/image-callout.yml@main |
| 94 | + with: |
| 95 | + project: ${{ inputs.project }} |
| 96 | + tag: ${{ needs.build.outputs.tag }} |
| 97 | + secrets: inherit |
0 commit comments