|
1 | | -name: Build docker Image |
| 1 | +name: Build container and chart |
2 | 2 |
|
3 | 3 | env: |
4 | 4 | IMAGE_PLATFORMS: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le |
5 | 5 |
|
6 | 6 | on: |
7 | | - workflow_dispatch: |
8 | | - push: |
9 | | - branches: |
10 | | - - main |
| 7 | + pull_request: |
| 8 | + branches-ignore: |
| 9 | + - "docu/**" |
11 | 10 | paths: |
12 | 11 | - "docker-image/**" |
| 12 | + - "helm/**" |
| 13 | + - ".github/workflows/**" |
13 | 14 |
|
14 | 15 | jobs: |
15 | | - generate_tag: |
| 16 | + generate_infos: |
16 | 17 | runs-on: ubuntu-latest |
17 | 18 | outputs: |
18 | | - output: ${{ steps.tag.outputs.tag }} |
| 19 | + releaseid: ${{ steps.tag.outputs.releaseid }} |
| 20 | + version: ${{ steps.tag.outputs.version }} |
| 21 | + pr: ${{ steps.tag.outputs.pr }} |
19 | 22 | steps: |
20 | 23 | - name: Check out the repo |
21 | 24 | uses: actions/checkout@v2 |
22 | | - with: |
23 | | - ref: main |
24 | | - fetch-depth: 0 |
25 | | - - id: tag |
| 25 | + - name: Setup awesome-ci |
| 26 | + uses: fullstack-devops/awesome-ci-action@main |
| 27 | + |
| 28 | + - name: collect infos and create release |
| 29 | + run: | |
| 30 | + awesome-ci pr info |
| 31 | + awesome-ci release create |
| 32 | + env: |
| 33 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + - name: collect infos |
| 36 | + id: tag |
26 | 37 | shell: bash |
27 | 38 | run: | |
28 | | - echo "Tag: $(git describe --abbrev=0)" |
29 | | - echo "::set-output name=tag::$(git describe --abbrev=0)" |
30 | | - |
| 39 | + echo "::set-output name=version::$ACI_VERSION" |
| 40 | + echo "::set-output name=pr::$ACI_PR" |
| 41 | + echo "::set-output name=releaseid::$ACI_RELEASE_ID" |
| 42 | +
|
31 | 43 | build-image: |
32 | 44 | runs-on: ubuntu-latest |
33 | | - needs: generate_tag |
| 45 | + needs: generate_infos |
34 | 46 | steps: |
35 | 47 | - name: Check out the repo |
36 | 48 | uses: actions/checkout@v2 |
|
56 | 68 | builder: ${{ steps.buildx.outputs.name }} |
57 | 69 | context: ./docker-image/ |
58 | 70 | platforms: ${{ env.IMAGE_PLATFORMS }} |
59 | | - push: true |
| 71 | + push: false |
60 | 72 | tags: | |
61 | 73 | ghcr.io/${{ github.repository }}:latest |
62 | | - ghcr.io/${{ github.repository }}:${{ needs.generate_tag.outputs.output }} |
| 74 | + ghcr.io/${{ github.repository }}:${{ needs.generate_infos.outputs.version }} |
| 75 | +
|
| 76 | + build-helm-chart: |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: generate_infos |
| 79 | + steps: |
| 80 | + - name: Check out the repo |
| 81 | + uses: actions/checkout@v2 |
| 82 | + |
| 83 | + - name: Helm Installation |
| 84 | + |
| 85 | + |
| 86 | + - name: Helm Package |
| 87 | + run: helm package ./helm --version "${{ needs.generate_infos.outputs.version }}" --app-version "${{ needs.generate_infos.outputs.version }}" -d out/ |
| 88 | + |
| 89 | + - name: Cache build outputs |
| 90 | + uses: actions/cache@v2 |
| 91 | + env: |
| 92 | + cache-name: cache-outputs-modules |
| 93 | + with: |
| 94 | + path: out/ |
| 95 | + key: dns-bind-${{ github.event.pull_request.head.sha }}-${{ hashFiles('out/dns-bind*') }} |
| 96 | + restore-keys: | |
| 97 | + dns-bind-${{ github.event.pull_request.head.sha }} |
| 98 | +
|
| 99 | + publish_release: |
| 100 | + runs-on: ubuntu-latest |
| 101 | + needs: [generate_infos, build-image, build-helm-chart] |
| 102 | + steps: |
| 103 | + - name: Checkout code |
| 104 | + uses: actions/checkout@v2 |
| 105 | + - name: Setup awesome-ci |
| 106 | + uses: fullstack-devops/awesome-ci-action@main |
| 107 | + |
| 108 | + - name: get cached build outputs |
| 109 | + uses: actions/cache@v2 |
| 110 | + env: |
| 111 | + cache-name: cache-outputs-modules |
| 112 | + with: |
| 113 | + path: out/ |
| 114 | + key: dns-bind-${{ github.event.pull_request.head.sha }} |
| 115 | + |
| 116 | + - name: Check out helm-charts |
| 117 | + uses: actions/checkout@v2 |
| 118 | + with: |
| 119 | + repository: fullstack-devops/helm-charts |
| 120 | + token: ${{ secrets.HELM_REPO_TOKEN }} |
| 121 | + ref: gh-pages |
| 122 | + persist-credentials: true |
| 123 | + path: helm-charts |
| 124 | + |
| 125 | + - name: Publish Release |
| 126 | + run: awesome-ci release publish -releaseid "$ACI_RELEASE_ID" -asstes "file=out/$ARTIFACT1" |
| 127 | + env: |
| 128 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + ACI_RELEASE_ID: ${{ needs.generate_infos.outputs.releaseid }} |
| 130 | + ARTIFACT1: dns-bind-${{ needs.generate_infos.outputs.version }}.tgz |
| 131 | + |
| 132 | + - name: Helm index |
| 133 | + env: |
| 134 | + GITHUB_TOKEN: ${{ secrets.HELM_REPO_TOKEN }} |
| 135 | + run: | |
| 136 | + git config user.name "$GITHUB_ACTOR" |
| 137 | + git config user.email "[email protected]" |
| 138 | +
|
| 139 | + helm repo index out/ --url "$ACI_ARTIFACT_1_URL" --merge helm-charts/index.yaml |
| 140 | + cp -f out/index.yaml helm-charts/index.yaml |
| 141 | +
|
| 142 | + cd helm-charts |
| 143 | + git push |
| 144 | + cat index.yaml |
0 commit comments