Publish Docker Image 🚢 #2
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: Publish Docker Image | |
| run-name: Publish Docker Image 🚢 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Version number (SemVer format MAJOR.MINOR.PATCH)" | |
| required: true | |
| default: "1.0.0" | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate SemVer format | |
| run: | | |
| VERSION="${{ inputs.version }}" | |
| SEMVER_REGEX="^[0-9]+\\.[0-9]+\\.[0-9]+$" | |
| if [[ ! "$VERSION" =~ $SEMVER_REGEX ]]; then | |
| echo "Error: Version '$VERSION' is not in SemVer format (MAJOR.MINOR.PATCH)." | |
| exit 1 | |
| fi | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 22 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push client Docker image | |
| run: | | |
| IMAGE_NAME=ghcr.io/localcrag/localcrag-backup | |
| TAG=${{ inputs.version }} | |
| docker build -t $IMAGE_NAME:$TAG -t $IMAGE_NAME:latest -f Dockerfile . | |
| docker push $IMAGE_NAME:$TAG | |
| docker push $IMAGE_NAME:latest |