|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + # pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - 'init' |
| 8 | + tags-ignore: |
| 9 | + - '*' |
| 10 | + paths-ignore: |
| 11 | + - 'demo/**' |
| 12 | + - 'docs/**' |
| 13 | + - 'LICENSE' |
| 14 | + - 'README.md' |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +env: |
| 18 | + DAGGER_VERSION: "0.13.7" |
| 19 | + DOCKER_REGISTRY: ${{ vars.DOCKER_REGISTRY }} |
| 20 | + DOCKER_REPOSITORY: ${{ vars.DOCKER_REPOSITORY }} |
| 21 | + DOCKER_REGISTRY_USERNAME: ${{ vars.DOCKER_REGISTRY_USERNAME }} |
| 22 | + DOCKER_REGISTRY_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} |
| 23 | + GH_DOCKER_REPOSITORY: ${{ vars.GH_DOCKER_REPOSITORY }} |
| 24 | + GH_HELM_REPOSITORY: ${{ vars.GH_HELM_REPOSITORY }} |
| 25 | + |
| 26 | +jobs: |
| 27 | + docker: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + target: ["debug", "prod"] |
| 33 | + |
| 34 | + permissions: |
| 35 | + contents: read |
| 36 | + packages: write |
| 37 | + attestations: write |
| 38 | + id-token: write |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v4 |
| 43 | + |
| 44 | + - name: Set short SHA |
| 45 | + id: sha |
| 46 | + run: echo "short_sha=${GITHUB_SHA::7}" >> $GITHUB_ENV |
| 47 | + |
| 48 | + - name: Set image tag |
| 49 | + id: tag |
| 50 | + run: | |
| 51 | + if [ "${{ github.ref }}" == "refs/heads/init" ]; then |
| 52 | + if [[ "${{ matrix.target }}" == "debug" ]]; then |
| 53 | + echo "tag=unstable-debug" >> $GITHUB_ENV |
| 54 | + else |
| 55 | + echo "tag=unstable" >> $GITHUB_ENV |
| 56 | + fi |
| 57 | + else |
| 58 | + if [[ "${{ matrix.target }}" == "debug" ]]; then |
| 59 | + echo "tag=build-${{ env.short_sha }}-debug" >> $GITHUB_ENV |
| 60 | + else |
| 61 | + echo "tag=build-${{ env.short_sha }}" >> $GITHUB_ENV |
| 62 | + fi |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: Publish Docker image |
| 66 | + uses: dagger/dagger-for-github@v6 |
| 67 | + env: |
| 68 | + GH_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 69 | + with: |
| 70 | + version: ${{ env.DAGGER_VERSION }} |
| 71 | + engine-stop: false |
| 72 | + module: github.com/opopops/daggerverse/[email protected] |
| 73 | + verb: call |
| 74 | + args: | |
| 75 | + --registry=${DOCKER_REGISTRY} \ |
| 76 | + --username=${DOCKER_REGISTRY_USERNAME} \ |
| 77 | + --password=env:DOCKER_REGISTRY_PASSWORD \ |
| 78 | + build \ |
| 79 | + --context=. \ |
| 80 | + --target=${{ matrix.target }} \ |
| 81 | + --platform=linux/amd64,linux/arm64 \ |
| 82 | + publish \ |
| 83 | + --image=${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}:${{ env.tag }} \ |
| 84 | +
|
| 85 | +
|
| 86 | + - name: Scan Docker image |
| 87 | + uses: dagger/dagger-for-github@v6 |
| 88 | + env: |
| 89 | + GH_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + with: |
| 91 | + version: ${{ env.DAGGER_VERSION }} |
| 92 | + module: github.com/opopops/daggerverse/[email protected] |
| 93 | + verb: call |
| 94 | + args: | |
| 95 | + with-registry-auth \ |
| 96 | + --address=ghcr.io \ |
| 97 | + --username=${{ github.actor }} \ |
| 98 | + --secret=env:GH_REGISTRY_PASSWORD \ |
| 99 | + scan \ |
| 100 | + --source=ghcr.io/${GH_DOCKER_REPOSITORY}:${{ env.tag }} \ |
| 101 | +
|
| 102 | + helm: |
| 103 | + runs-on: ubuntu-latest |
| 104 | + |
| 105 | + permissions: |
| 106 | + contents: read |
| 107 | + packages: write |
| 108 | + attestations: write |
| 109 | + id-token: write |
| 110 | + |
| 111 | + steps: |
| 112 | + - name: Checkout |
| 113 | + uses: actions/checkout@v4 |
| 114 | + |
| 115 | + - name: Lint |
| 116 | + uses: dagger/dagger-for-github@v6 |
| 117 | + with: |
| 118 | + version: ${{ env.DAGGER_VERSION }} |
| 119 | + engine-stop: false |
| 120 | + module: github.com/purpleclay/daggerverse/[email protected] |
| 121 | + verb: call |
| 122 | + args: | |
| 123 | + lint \ |
| 124 | + --dir chart \ |
| 125 | + --strict \ |
| 126 | +
|
| 127 | + - name: Publish Helm chart |
| 128 | + uses: dagger/dagger-for-github@v6 |
| 129 | + env: |
| 130 | + GH_REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 131 | + with: |
| 132 | + version: ${{ env.DAGGER_VERSION }} |
| 133 | + engine-stop: false |
| 134 | + module: github.com/purpleclay/daggerverse/[email protected] |
| 135 | + verb: call |
| 136 | + args: | |
| 137 | + package-push \ |
| 138 | + --dir chart \ |
| 139 | + --version="0.0.0" \ |
| 140 | + --appVersion="1.0.0" \ |
| 141 | + --registry=ghcr.io/${GH_HELM_REPOSITORY} \ |
| 142 | + --username=${{ github.actor }} \ |
| 143 | + --password=env:GH_REGISTRY_PASSWORD \ |
0 commit comments