Merge pull request #73 from joshrotenberg/feat/add-missing-cli-commands #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: joshrotenberg/redisctl | |
| jobs: | |
| build-and-push: | |
| name: Build and Push Docker Image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=semver,pattern={{version}},value=${{ github.ref_name }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }} | |
| type=semver,pattern={{major}},value=${{ github.ref_name }} | |
| type=sha,prefix=sha- | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set build parameters | |
| id: build-params | |
| run: | | |
| if [[ "${{ github.event_name }}" == "release" ]]; then | |
| VERSION="${{ github.event.release.tag_name }}" | |
| VERSION="${VERSION#redisctl-v}" | |
| echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "DOCKERFILE=./Dockerfile" >> $GITHUB_OUTPUT | |
| echo "PLATFORMS=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT | |
| else | |
| echo "VERSION=dev" >> $GITHUB_OUTPUT | |
| echo "DOCKERFILE=./Dockerfile.dev" >> $GITHUB_OUTPUT | |
| echo "PLATFORMS=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ steps.build-params.outputs.DOCKERFILE }} | |
| platforms: ${{ steps.build-params.outputs.PLATFORMS }} | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| VERSION=${{ steps.build-params.outputs.VERSION }} | |
| - name: Update Docker Hub Description | |
| uses: peter-evans/dockerhub-description@v4 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: ${{ env.IMAGE_NAME }} | |
| short-description: "Unified CLI for Redis Cloud and Enterprise management" | |
| readme-filepath: ./README.md |