Fix deploy action tags and docs
- commit
- ce7d45edd03f743eaf130538a18d8a11b16fc5be
- author
- bnema · · 2026-01-13 21:19 UTC
- parent
- b462a18
- signature
- unsigned
4 files · +27 -7
M .github/actions/deploy/README.md +2 -0
| @@ -85,6 +85,7 @@ jobs: | |||
| 85 | 85 | | `username` | Registry username (token subject for token auth) | Yes | - | | |
| 86 | 86 | | `password` | Registry password or token | Yes | - | | |
| 87 | 87 | | `image` | Image name | No | Repository name | | |
| 88 | + | | `tag` | Override image tag | No | Git tag or short SHA | | |
| 88 | 89 | | `dockerfile` | Path to Dockerfile | No | `./Dockerfile` | | |
| 89 | 90 | | `context` | Build context path | No | `.` | | |
| 90 | 91 | | `build-args` | Build arguments (one per line) | No | - | | |
| @@ -163,6 +164,7 @@ jobs: | |||
| 163 | 164 | registry: registry.mydomain.com | |
| 164 | 165 | username: ${{ secrets.GORDON_USERNAME }} | |
| 165 | 166 | password: ${{ secrets.GORDON_TOKEN }} | |
| 167 | + | tag: ${{ github.event.inputs.tag }} | |
| 166 | 168 | ``` | |
| 167 | 169 | ||
| 168 | 170 | ### Monorepo with Multiple Services | |
| @@ -85,6 +85,7 @@ jobs: | |||||
| 85 | | `username` | Registry username (token subject for token auth) | Yes | - | | 85 | | `username` | Registry username (token subject for token auth) | Yes | - | | ||
| 86 | | `password` | Registry password or token | Yes | - | | 86 | | `password` | Registry password or token | Yes | - | | ||
| 87 | | `image` | Image name | No | Repository name | | 87 | | `image` | Image name | No | Repository name | | ||
| 88 | + | | `tag` | Override image tag | No | Git tag or short SHA | | |||
| 88 | | `dockerfile` | Path to Dockerfile | No | `./Dockerfile` | | 89 | | `dockerfile` | Path to Dockerfile | No | `./Dockerfile` | | ||
| 89 | | `context` | Build context path | No | `.` | | 90 | | `context` | Build context path | No | `.` | | ||
| 90 | | `build-args` | Build arguments (one per line) | No | - | | 91 | | `build-args` | Build arguments (one per line) | No | - | | ||
| @@ -163,6 +164,7 @@ jobs: | |||||
| 163 | registry: registry.mydomain.com | 164 | registry: registry.mydomain.com | ||
| 164 | username: ${{ secrets.GORDON_USERNAME }} | 165 | username: ${{ secrets.GORDON_USERNAME }} | ||
| 165 | password: ${{ secrets.GORDON_TOKEN }} | 166 | password: ${{ secrets.GORDON_TOKEN }} | ||
| 167 | + | tag: ${{ github.event.inputs.tag }} | |||
| 166 | ``` | 168 | ``` | ||
| 167 | 169 | ||||
| 168 | ### Monorepo with Multiple Services | 170 | ### Monorepo with Multiple Services | ||
M .github/actions/deploy/action.yml +23 -6
| @@ -20,6 +20,10 @@ inputs: | |||
| 20 | 20 | description: 'Image name (defaults to repository name)' | |
| 21 | 21 | required: false | |
| 22 | 22 | default: '' | |
| 23 | + | tag: | |
| 24 | + | description: 'Override image tag (defaults to git tag or short SHA)' | |
| 25 | + | required: false | |
| 26 | + | default: '' | |
| 23 | 27 | dockerfile: | |
| 24 | 28 | description: 'Path to Dockerfile (defaults to ./Dockerfile)' | |
| 25 | 29 | required: false | |
| @@ -81,11 +85,13 @@ runs: | |||
| 81 | 85 | IMAGE_NAME="${GITHUB_REPOSITORY#*/}" | |
| 82 | 86 | fi | |
| 83 | 87 | ||
| 84 | - | # Extract tag from ref | |
| 85 | - | if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| 88 | + | # Extract tag from ref (or override) | |
| 89 | + | if [[ -n "${{ inputs.tag }}" ]]; then | |
| 90 | + | TAG="${{ inputs.tag }}" | |
| 91 | + | elif [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
| 86 | 92 | TAG="${GITHUB_REF#refs/tags/}" | |
| 87 | 93 | else | |
| 88 | - | TAG="$(echo $GITHUB_SHA | head -c 7)" | |
| 94 | + | TAG="$(echo "$GITHUB_SHA" | head -c 7)" | |
| 89 | 95 | fi | |
| 90 | 96 | ||
| 91 | 97 | # Full image reference | |
| @@ -98,6 +104,9 @@ runs: | |||
| 98 | 104 | ||
| 99 | 105 | echo "Building: ${FULL_IMAGE}" | |
| 100 | 106 | ||
| 107 | + | - name: Set up QEMU | |
| 108 | + | uses: docker/setup-qemu-action@v3 | |
| 109 | + | ||
| 101 | 110 | - name: Set up Docker Buildx | |
| 102 | 111 | uses: docker/setup-buildx-action@v3 | |
| 103 | 112 | ||
| @@ -108,6 +117,16 @@ runs: | |||
| 108 | 117 | username: ${{ inputs.username }} | |
| 109 | 118 | password: ${{ inputs.password }} | |
| 110 | 119 | ||
| 120 | + | - name: Build tags | |
| 121 | + | id: tags | |
| 122 | + | shell: bash | |
| 123 | + | run: | | |
| 124 | + | TAGS="${{ steps.meta.outputs.image }}" | |
| 125 | + | if [[ "${{ inputs.push-latest }}" == "true" ]]; then | |
| 126 | + | TAGS="${TAGS}"$'\n'"${{ inputs.registry }}/${{ steps.meta.outputs.image_name }}:latest" | |
| 127 | + | fi | |
| 128 | + | printf "tags<<EOF\n%s\nEOF\n" "$TAGS" >> "$GITHUB_OUTPUT" | |
| 129 | + | ||
| 111 | 130 | - name: Build and push | |
| 112 | 131 | id: push | |
| 113 | 132 | uses: docker/build-push-action@v6 | |
| @@ -117,9 +136,7 @@ runs: | |||
| 117 | 136 | context: ${{ inputs.context }} | |
| 118 | 137 | file: ${{ inputs.dockerfile }} | |
| 119 | 138 | push: true | |
| 120 | - | tags: | | |
| 121 | - | ${{ steps.meta.outputs.image }} | |
| 122 | - | ${{ inputs.push-latest == 'true' && format('{0}/{1}:latest', inputs.registry, steps.meta.outputs.image_name) || '' }} | |
| 139 | + | tags: ${{ steps.tags.outputs.tags }} | |
| 123 | 140 | build-args: ${{ inputs.build-args }} | |
| 124 | 141 | platforms: ${{ inputs.platforms }} | |
| 125 | 142 | cache-from: ${{ inputs.cache-from }} | |
| @@ -20,6 +20,10 @@ inputs: | |||||
| 20 | description: 'Image name (defaults to repository name)' | 20 | description: 'Image name (defaults to repository name)' | ||
| 21 | required: false | 21 | required: false | ||
| 22 | default: '' | 22 | default: '' | ||
| 23 | + | tag: | |||
| 24 | + | description: 'Override image tag (defaults to git tag or short SHA)' | |||
| 25 | + | required: false | |||
| 26 | + | default: '' | |||
| 23 | dockerfile: | 27 | dockerfile: | ||
| 24 | description: 'Path to Dockerfile (defaults to ./Dockerfile)' | 28 | description: 'Path to Dockerfile (defaults to ./Dockerfile)' | ||
| 25 | required: false | 29 | required: false | ||
| @@ -81,11 +85,13 @@ runs: | |||||
| 81 | IMAGE_NAME="${GITHUB_REPOSITORY#*/}" | 85 | IMAGE_NAME="${GITHUB_REPOSITORY#*/}" | ||
| 82 | fi | 86 | fi | ||
| 83 | 87 | ||||
| 84 | - | # Extract tag from ref | 88 | + | # Extract tag from ref (or override) |
| 85 | - | if [[ "$GITHUB_REF" == refs/tags/* ]]; then | 89 | + | if [[ -n "${{ inputs.tag }}" ]]; then |
| 90 | + | TAG="${{ inputs.tag }}" | |||
| 91 | + | elif [[ "$GITHUB_REF" == refs/tags/* ]]; then | |||
| 86 | TAG="${GITHUB_REF#refs/tags/}" | 92 | TAG="${GITHUB_REF#refs/tags/}" | ||
| 87 | else | 93 | else | ||
| 88 | - | TAG="$(echo $GITHUB_SHA | head -c 7)" | 94 | + | TAG="$(echo "$GITHUB_SHA" | head -c 7)" |
| 89 | fi | 95 | fi | ||
| 90 | 96 | ||||
| 91 | # Full image reference | 97 | # Full image reference | ||
| @@ -98,6 +104,9 @@ runs: | |||||
| 98 | 104 | ||||
| 99 | echo "Building: ${FULL_IMAGE}" | 105 | echo "Building: ${FULL_IMAGE}" | ||
| 100 | 106 | ||||
| 107 | + | - name: Set up QEMU | |||
| 108 | + | uses: docker/setup-qemu-action@v3 | |||
| 109 | + | ||||
| 101 | - name: Set up Docker Buildx | 110 | - name: Set up Docker Buildx | ||
| 102 | uses: docker/setup-buildx-action@v3 | 111 | uses: docker/setup-buildx-action@v3 | ||
| 103 | 112 | ||||
| @@ -108,6 +117,16 @@ runs: | |||||
| 108 | username: ${{ inputs.username }} | 117 | username: ${{ inputs.username }} | ||
| 109 | password: ${{ inputs.password }} | 118 | password: ${{ inputs.password }} | ||
| 110 | 119 | ||||
| 120 | + | - name: Build tags | |||
| 121 | + | id: tags | |||
| 122 | + | shell: bash | |||
| 123 | + | run: | | |||
| 124 | + | TAGS="${{ steps.meta.outputs.image }}" | |||
| 125 | + | if [[ "${{ inputs.push-latest }}" == "true" ]]; then | |||
| 126 | + | TAGS="${TAGS}"$'\n'"${{ inputs.registry }}/${{ steps.meta.outputs.image_name }}:latest" | |||
| 127 | + | fi | |||
| 128 | + | printf "tags<<EOF\n%s\nEOF\n" "$TAGS" >> "$GITHUB_OUTPUT" | |||
| 129 | + | ||||
| 111 | - name: Build and push | 130 | - name: Build and push | ||
| 112 | id: push | 131 | id: push | ||
| 113 | uses: docker/build-push-action@v6 | 132 | uses: docker/build-push-action@v6 | ||
| @@ -117,9 +136,7 @@ runs: | |||||
| 117 | context: ${{ inputs.context }} | 136 | context: ${{ inputs.context }} | ||
| 118 | file: ${{ inputs.dockerfile }} | 137 | file: ${{ inputs.dockerfile }} | ||
| 119 | push: true | 138 | push: true | ||
| 120 | - | tags: | | 139 | + | tags: ${{ steps.tags.outputs.tags }} |
| 121 | - | ${{ steps.meta.outputs.image }} | |||
| 122 | - | ${{ inputs.push-latest == 'true' && format('{0}/{1}:latest', inputs.registry, steps.meta.outputs.image_name) || '' }} | |||
| 123 | build-args: ${{ inputs.build-args }} | 140 | build-args: ${{ inputs.build-args }} | ||
| 124 | platforms: ${{ inputs.platforms }} | 141 | platforms: ${{ inputs.platforms }} | ||
| 125 | cache-from: ${{ inputs.cache-from }} | 142 | cache-from: ${{ inputs.cache-from }} | ||
M .github/dependabot.yml +1 -1
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | 6 | version: 2 | |
| 7 | 7 | updates: | |
| 8 | - | - package-ecosystem: "" # See documentation for possible values | |
| 8 | + | - package-ecosystem: "gomod" # See documentation for possible values | |
| 9 | 9 | directory: "/" # Location of package manifests | |
| 10 | 10 | schedule: | |
| 11 | 11 | interval: "weekly" | |
| @@ -5,7 +5,7 @@ | |||||
| 5 | 5 | ||||
| 6 | version: 2 | 6 | version: 2 | ||
| 7 | updates: | 7 | updates: | ||
| 8 | - | - package-ecosystem: "" # See documentation for possible values | 8 | + | - package-ecosystem: "gomod" # See documentation for possible values |
| 9 | directory: "/" # Location of package manifests | 9 | directory: "/" # Location of package manifests | ||
| 10 | schedule: | 10 | schedule: | ||
| 11 | interval: "weekly" | 11 | interval: "weekly" | ||
M examples/github-workflow.yml +1 -0
| @@ -48,6 +48,7 @@ jobs: | |||
| 48 | 48 | registry: ${{ secrets.GORDON_REGISTRY }} | |
| 49 | 49 | username: ${{ secrets.GORDON_USERNAME }} | |
| 50 | 50 | password: ${{ secrets.GORDON_TOKEN }} | |
| 51 | + | tag: ${{ github.event.inputs.tag }} | |
| 51 | 52 | # Optional customizations: | |
| 52 | 53 | # image: myapp # Custom image name (defaults to repo name) | |
| 53 | 54 | # dockerfile: ./Dockerfile # Custom Dockerfile path | |
| @@ -48,6 +48,7 @@ jobs: | |||||
| 48 | registry: ${{ secrets.GORDON_REGISTRY }} | 48 | registry: ${{ secrets.GORDON_REGISTRY }} | ||
| 49 | username: ${{ secrets.GORDON_USERNAME }} | 49 | username: ${{ secrets.GORDON_USERNAME }} | ||
| 50 | password: ${{ secrets.GORDON_TOKEN }} | 50 | password: ${{ secrets.GORDON_TOKEN }} | ||
| 51 | + | tag: ${{ github.event.inputs.tag }} | |||
| 51 | # Optional customizations: | 52 | # Optional customizations: | ||
| 52 | # image: myapp # Custom image name (defaults to repo name) | 53 | # image: myapp # Custom image name (defaults to repo name) | ||
| 53 | # dockerfile: ./Dockerfile # Custom Dockerfile path | 54 | # dockerfile: ./Dockerfile # Custom Dockerfile path | ||