|
| 1 | +# a pipeline to create container image on changes to aiden-cli.rb file |
| 2 | +name: aiden-cli |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - 'aiden-cli.rb' |
| 9 | + - aiden-cli/Dockerfile |
| 10 | + - .github/workflows/aiden-cli.yaml |
| 11 | +env: |
| 12 | + REGISTRY: ghcr.io |
| 13 | + IMAGE_NAME: stackgenhq/aiden-cli |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + outputs: |
| 17 | + image_tag: ${{ steps.meta.outputs.tags }} |
| 18 | + version: ${{ steps.version.outputs.VERSION }} |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + strategy: |
| 23 | + fail-fast: false |
| 24 | + matrix: |
| 25 | + include: |
| 26 | + - platform: linux/amd64 |
| 27 | + runner: ubuntu-latest |
| 28 | + tag-suffix: -amd |
| 29 | + - platform: linux/arm64 |
| 30 | + runner: ubuntu-22.04-arm |
| 31 | + tag-suffix: -arm |
| 32 | + runs-on: ${{ matrix.runner }} |
| 33 | + steps: |
| 34 | + - name: Checkout |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 1 |
| 38 | + sparse-checkout: | |
| 39 | + aiden-cli |
| 40 | + aiden-cli.rb |
| 41 | + - name: Get aiden-cli version |
| 42 | + id: version |
| 43 | + run: | |
| 44 | + echo "VERSION=$(grep 'version' aiden-cli.rb | awk '{print $NF}' | tr -d '"')" >> $GITHUB_OUTPUT |
| 45 | + - name: Set up QEMU |
| 46 | + uses: docker/setup-qemu-action@v3 |
| 47 | + - name: Set up Docker Buildx |
| 48 | + uses: docker/setup-buildx-action@v3 |
| 49 | + - name: Extract metadata (tags, labels) for Docker |
| 50 | + id: meta |
| 51 | + uses: docker/metadata-action@v5 |
| 52 | + with: |
| 53 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 54 | + tags: | |
| 55 | + type=raw,value=${{ steps.version.outputs.VERSION }} |
| 56 | + type=raw,value=latest |
| 57 | + flavor: | |
| 58 | + suffix=${{ matrix.tag-suffix }},onlatest=false |
| 59 | + - name: Log in to the Container registry |
| 60 | + uses: docker/login-action@v3 |
| 61 | + with: |
| 62 | + registry: ${{ env.REGISTRY }} |
| 63 | + username: ${{ github.actor }} |
| 64 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + - name: Docker Build and push |
| 66 | + uses: docker/build-push-action@v6 |
| 67 | + with: |
| 68 | + context: ./aiden-cli |
| 69 | + platforms: ${{ matrix.platform }} |
| 70 | + tags: ${{ steps.meta.outputs.tags }} |
| 71 | + push: true |
| 72 | + provenance: false |
| 73 | + labels: ${{ steps.meta.outputs.labels }} |
| 74 | + build-args: |- |
| 75 | + AIDEN_CLI_VERSION=${{ steps.version.outputs.VERSION }} |
| 76 | +
|
| 77 | + create_manifest: |
| 78 | + name: Create manifest |
| 79 | + runs-on: ubuntu-22.04 |
| 80 | + needs: build |
| 81 | + permissions: |
| 82 | + contents: read |
| 83 | + packages: write |
| 84 | + steps: |
| 85 | + - name: Set up Docker Buildx |
| 86 | + uses: docker/setup-buildx-action@v3 |
| 87 | + - name: Log in to the Container registry |
| 88 | + uses: docker/login-action@v3 |
| 89 | + with: |
| 90 | + registry: ${{ env.REGISTRY }} |
| 91 | + username: ${{ github.actor }} |
| 92 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + - name: Create manifest |
| 94 | + run: | |
| 95 | + docker buildx imagetools create \ |
| 96 | + -t ghcr.io/stackgenhq/aiden-cli:latest \ |
| 97 | + ghcr.io/stackgenhq/aiden-cli:latest-amd \ |
| 98 | + ghcr.io/stackgenhq/aiden-cli:latest-arm |
| 99 | +
|
| 100 | + docker buildx imagetools create \ |
| 101 | + -t ghcr.io/stackgenhq/aiden-cli:${{ needs.build.outputs.version }} \ |
| 102 | + ghcr.io/stackgenhq/aiden-cli:${{ needs.build.outputs.version }}-amd \ |
| 103 | + ghcr.io/stackgenhq/aiden-cli:${{ needs.build.outputs.version }}-arm |
0 commit comments