Fix denylist bypass via quoted commands (#472) #151
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 Build | |
| on: | |
| push: | |
| branches: | |
| - 'main' | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| env: | |
| PUBLISH_DOCKERHUB: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }} | |
| PUBLISH_GHCR: ${{ github.repository == 'valkey-io/valkey-admin' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }} | |
| PUBLISH_ECR: ${{ secrets.AWS_ROLE_TO_ASSUME != '' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }} | |
| defaults: | |
| run: | |
| shell: 'bash -Eeuo pipefail -x {0}' | |
| jobs: | |
| build-and-push: | |
| name: Build and push Docker image | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Login to Docker Hub | |
| if: env.PUBLISH_DOCKERHUB == 'true' | |
| uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to GitHub Container Registry | |
| if: env.PUBLISH_GHCR == 'true' | |
| uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Configure AWS credentials via OIDC | |
| if: env.PUBLISH_ECR == 'true' | |
| uses: aws-actions/configure-aws-credentials@8df5847569e6427dd6c4fb1cf565c83acfa8afa7 # v6.0.0 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} | |
| aws-region: us-east-1 | |
| - name: Login to Amazon ECR Public Gallery | |
| if: env.PUBLISH_ECR == 'true' | |
| run: | | |
| aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws | |
| - name: Generate tags | |
| id: tags | |
| run: | | |
| all_tags="" | |
| version_tag="" | |
| if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| version_tag="${{ github.ref_name }}" | |
| version_tag="${version_tag#v}" | |
| fi | |
| if [[ "$PUBLISH_DOCKERHUB" == "true" ]]; then | |
| if [[ -n "$version_tag" ]]; then | |
| tags="${{ secrets.DOCKERHUB_REPOSITORY }}:latest,${{ secrets.DOCKERHUB_REPOSITORY }}:$version_tag" | |
| else | |
| tags="${{ secrets.DOCKERHUB_REPOSITORY }}:edge" | |
| fi | |
| all_tags="$tags" | |
| fi | |
| if [[ "$PUBLISH_GHCR" == "true" ]]; then | |
| if [[ -n "$version_tag" ]]; then | |
| tags="ghcr.io/${{ github.repository_owner }}/valkey-admin:latest,ghcr.io/${{ github.repository_owner }}/valkey-admin:$version_tag" | |
| else | |
| tags="ghcr.io/${{ github.repository_owner }}/valkey-admin:edge" | |
| fi | |
| all_tags="${all_tags:+$all_tags,}$tags" | |
| fi | |
| if [[ "$PUBLISH_ECR" == "true" ]]; then | |
| if [[ -n "$version_tag" ]]; then | |
| tags="public.ecr.aws/${{ secrets.ECR_REGISTRY_ALIAS }}/${{ secrets.ECR_REPOSITORY_NAME }}:latest,public.ecr.aws/${{ secrets.ECR_REGISTRY_ALIAS }}/${{ secrets.ECR_REPOSITORY_NAME }}:$version_tag" | |
| else | |
| tags="public.ecr.aws/${{ secrets.ECR_REGISTRY_ALIAS }}/${{ secrets.ECR_REPOSITORY_NAME }}:edge" | |
| fi | |
| all_tags="${all_tags:+$all_tags,}$tags" | |
| fi | |
| echo "tags=$all_tags" >> "$GITHUB_OUTPUT" | |
| - name: Build and push | |
| uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 | |
| with: | |
| context: . | |
| file: ./docker/Dockerfile.app | |
| push: ${{ env.PUBLISH_DOCKERHUB == 'true' || env.PUBLISH_GHCR == 'true' || env.PUBLISH_ECR == 'true' }} | |
| tags: ${{ steps.tags.outputs.tags }} | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: false | |
| - name: Update Docker Hub description | |
| if: env.PUBLISH_DOCKERHUB == 'true' | |
| uses: peter-evans/dockerhub-description@1b9a80c056b620d92cedb9d9b5a223409c68ddfa # v5.0.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: ${{ secrets.DOCKERHUB_REPOSITORY }} | |
| readme-filepath: ./docker/description.md | |
| short-description: 'Valkey Admin is a web-based administration tool for Valkey clusters and standalone instances.' | |
| - name: Update ECR Public description | |
| if: env.PUBLISH_ECR == 'true' | |
| run: | | |
| ABOUT=$(cat docker/description.md | head -c 10240 | jq -Rs .) | |
| aws ecr-public put-repository-catalog-data \ | |
| --region us-east-1 \ | |
| --repository-name "${{ secrets.ECR_REPOSITORY_NAME }}" \ | |
| --catalog-data "{\"aboutText\":$ABOUT,\"description\":\"Valkey Admin is a web-based administration tool for Valkey clusters and standalone instances.\"}" |