📦 Publish Docker Images #21
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
| # GitHub recommends pinning actions to a commit SHA. | |
| # To get a newer version, you will need to update the SHA. | |
| # You can also reference a tag or branch, but the action may change without warning. | |
| name: ' 📦 Publish Docker Images' | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| dryRun: | |
| description: 'Dry Run' | |
| type: choice | |
| options: | |
| - 'yes' | |
| - 'no' | |
| default: 'no' | |
| required: false | |
| ref: | |
| description: 'Reference / tag to publish' | |
| required: false | |
| type: string | |
| workflow_call: | |
| inputs: | |
| ref: | |
| description: 'Reference / tag to publish' | |
| required: true | |
| type: string | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: 'streetsidesoftware/cspell' | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| env: | |
| DEBUG: ${{ github.event.inputs.dryRun == 'yes'}} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 | |
| with: | |
| ref: ${{ github.event.inputs.ref || github.ref }} | |
| - name: CSpell Version | |
| run: | | |
| export CSPELL_VERSION=$(jq -r ".dependencies.cspell | sub(\"[_^]\"; \"\")" package.json) | |
| echo CSPELL_VERSION=$CSPELL_VERSION >> $GITHUB_ENV | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ env.CSPELL_VERSION }} | |
| labels: | | |
| org.opencontainers.image.title=cspell | |
| org.opencontainers.image.description=CSpell command line spell checker for code and other documents. | |
| org.opencontainers.image.vendor=Street Side Software | |
| - name: Log Docker metadata | |
| env: | |
| META: $${{ toJSON(steps.meta.outputs) }} | |
| run: echo "$META" | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 | |
| if: ${{ env.DEBUG != 'true' }} | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| # cspell:ignore opencontainers |