Workflow file for this run
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: TypeScript Node - Release | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
environment: PRODUCTION | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 | |
- name: Login to Docker Hub | |
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 | |
with: | |
username: ${{ vars.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GHCR | |
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Generate build tag | |
run: | | |
RELEASE_NAME="${{ github.event.release.name }}" | |
if [[ -z "$RELEASE_NAME" ]]; then | |
echo "Error: Release name is empty" | |
exit 1 | |
fi | |
# Check if it's a valid semver (with optional 'v' prefix) | |
if [[ "$RELEASE_NAME" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then | |
# Strip 'v' prefix if present | |
CLEAN_VERSION="${RELEASE_NAME#v}" | |
echo "BUILD_TAG=$CLEAN_VERSION" >> $GITHUB_ENV | |
else | |
echo "Error: Release name '$RELEASE_NAME' is not a valid semantic version" | |
exit 1 | |
fi | |
- name: Build & Push image to registries | |
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 | |
with: | |
context: source/typescript-node | |
push: true | |
tags: | | |
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:${{ env.BUILD_TAG }} | |
${{ vars.DOCKERHUB_USERNAME }}/typescript-node:latest | |
ghcr.io/${{ github.repository_owner }}/typescript-node:${{ env.BUILD_TAG }} | |
ghcr.io/${{ github.repository_owner }}/typescript-node:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |