|
| 1 | +name: 'Push to docker' |
| 2 | +description: 'Builds packages and pushes a docker image to GHCR' |
| 3 | + |
| 4 | +inputs: |
| 5 | + github-actor: |
| 6 | + description: 'Github actor' |
| 7 | + required: true |
| 8 | + github-secret: |
| 9 | + description: 'Github secret' |
| 10 | + required: true |
| 11 | + ref-name: |
| 12 | + description: 'Github ref name' |
| 13 | + required: true |
| 14 | + github-sha: |
| 15 | + description: 'Github Commit SHA Hash' |
| 16 | + required: true |
| 17 | + |
| 18 | +runs: |
| 19 | + using: 'composite' |
| 20 | + steps: |
| 21 | + - name: 'Checkout' |
| 22 | + uses: 'actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955' # ratchet:actions/checkout@v4 |
| 23 | + with: |
| 24 | + ref: '${{ inputs.github-sha }}' |
| 25 | + fetch-depth: 0 |
| 26 | + - name: 'Install Dependencies' |
| 27 | + shell: 'bash' |
| 28 | + run: 'npm install' |
| 29 | + - name: 'Set up Docker Buildx' |
| 30 | + uses: 'docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435' # ratchet:docker/setup-buildx-action@v3 |
| 31 | + - name: 'build' |
| 32 | + shell: 'bash' |
| 33 | + run: 'npm run build' |
| 34 | + - name: 'pack @google/gemini-cli' |
| 35 | + shell: 'bash' |
| 36 | + run: 'npm pack -w @google/gemini-cli --pack-destination ./packages/cli/dist' |
| 37 | + - name: 'pack @google/gemini-cli-core' |
| 38 | + shell: 'bash' |
| 39 | + run: 'npm pack -w @google/gemini-cli-core --pack-destination ./packages/core/dist' |
| 40 | + - name: 'Log in to GitHub Container Registry' |
| 41 | + uses: 'docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1' # ratchet:docker/login-action@v3 |
| 42 | + with: |
| 43 | + registry: 'ghcr.io' |
| 44 | + username: '${{ inputs.github-actor }}' |
| 45 | + password: '${{ inputs.github-secret }}' |
| 46 | + - name: 'Get branch name' |
| 47 | + id: 'branch_name' |
| 48 | + shell: 'bash' |
| 49 | + run: | |
| 50 | + REF_NAME="${{ inputs.ref-name }}" |
| 51 | + echo "name=${REF_NAME%/merge}" >> $GITHUB_OUTPUT |
| 52 | + - name: 'Build and Push the Docker Image' |
| 53 | + uses: 'docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83' # ratchet:docker/build-push-action@v6 |
| 54 | + with: |
| 55 | + context: '.' |
| 56 | + file: './Dockerfile' |
| 57 | + push: true |
| 58 | + provenance: false # avoid pushing 3 images to Aritfact Registry |
| 59 | + tags: | |
| 60 | + ghcr.io/${{ github.repository }}/cli:${{ steps.branch_name.outputs.name }} |
| 61 | + ghcr.io/${{ github.repository }}/cli:${{ inputs.github-sha }} |
| 62 | + - name: 'Create issue on failure' |
| 63 | + if: |- |
| 64 | + ${{ failure() }} |
| 65 | + shell: 'bash' |
| 66 | + env: |
| 67 | + GITHUB_TOKEN: '${{ inputs.github-secret }}' |
| 68 | + DETAILS_URL: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
| 69 | + run: |- |
| 70 | + gh issue create \ |
| 71 | + --title "Docker build failed" \ |
| 72 | + --body "The docker build failed. See the full run for details: ${DETAILS_URL}" \ |
| 73 | + --label "kind/bug,release-failure" |
0 commit comments