|
| 1 | +name: Branch |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + tags: |
| 11 | + - "v*" |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +permissions: |
| 18 | + actions: write |
| 19 | + checks: write |
| 20 | + contents: write |
| 21 | + deployments: write |
| 22 | + id-token: write |
| 23 | + issues: write |
| 24 | + discussions: write |
| 25 | + packages: write |
| 26 | + pages: write |
| 27 | + pull-requests: write |
| 28 | + repository-projects: write |
| 29 | + security-events: write |
| 30 | + statuses: write |
| 31 | + |
| 32 | +jobs: |
| 33 | + check: |
| 34 | + strategy: |
| 35 | + fail-fast: true |
| 36 | + |
| 37 | + name: Chaincode project |
| 38 | + runs-on: namespace-profile-fabric-chaincode |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: namespacelabs/nscloud-checkout-action@v2 |
| 42 | + with: |
| 43 | + submodules: recursive |
| 44 | + |
| 45 | + - name: Setup caches |
| 46 | + uses: namespacelabs/nscloud-cache-action@v1 |
| 47 | + with: |
| 48 | + path: | |
| 49 | + cache |
| 50 | + out |
| 51 | + ~/.node_modules |
| 52 | +
|
| 53 | + - name: Install Cosign |
| 54 | + uses: sigstore/cosign-installer@v3 |
| 55 | + |
| 56 | + - name: Login to GitHub Container Registry |
| 57 | + uses: docker/login-action@v3 |
| 58 | + with: |
| 59 | + registry: ghcr.io |
| 60 | + username: ${{ github.repository_owner }} |
| 61 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + |
| 63 | + - name: Login to DockerHub |
| 64 | + uses: docker/login-action@v3 |
| 65 | + with: |
| 66 | + username: ${{ secrets.DOCKERHUB_USER }} |
| 67 | + password: ${{ secrets.DOCKERHUB_PASS }} |
| 68 | + |
| 69 | + - name: Docker meta |
| 70 | + id: docker_meta |
| 71 | + uses: docker/metadata-action@v5 |
| 72 | + with: |
| 73 | + # list of Docker images to use as base name for tags |
| 74 | + images: | |
| 75 | + ghcr.io/settlemint/chaincode-typescript-empty-pdc |
| 76 | + # generate Docker tags based on the following events/attributes |
| 77 | + tags: | |
| 78 | + type=schedule |
| 79 | + type=ref,event=branch |
| 80 | + type=ref,event=pr |
| 81 | + type=semver,pattern={{version}} |
| 82 | + type=semver,pattern={{major}}.{{minor}} |
| 83 | + type=semver,pattern={{major}} |
| 84 | + type=sha |
| 85 | +
|
| 86 | + - name: Build and push |
| 87 | + uses: docker/build-push-action@v5 |
| 88 | + id: build-and-push |
| 89 | + with: |
| 90 | + load: false |
| 91 | + provenance: true |
| 92 | + sbom: true |
| 93 | + push: true |
| 94 | + platforms: linux/amd64,linux/arm64 |
| 95 | + tags: ${{ steps.docker_meta.outputs.tags }} |
| 96 | + labels: ${{ steps.docker_meta.outputs.labels }} |
| 97 | + no-cache: true |
| 98 | + |
| 99 | + - name: Sign the images with GitHub OIDC Token |
| 100 | + env: |
| 101 | + DIGEST: ${{ steps.build-and-push.outputs.digest }} |
| 102 | + TAGS: ${{ steps.docker_meta.outputs.tags }} |
| 103 | + run: | |
| 104 | + images="" |
| 105 | + for tag in ${TAGS}; do |
| 106 | + images+="${tag}@${DIGEST} " |
| 107 | + done |
| 108 | + cosign sign --yes ${images} |
0 commit comments