feat(ci): Added script to build and push docker image based on tag #138
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: semantic-release-versioning | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write # semantic-release still needs these | ||
issues: write | ||
pull-requests: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # semantic-release needs full history + tags | ||
persist-credentials: false | ||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v2 | ||
with: | ||
bun-version: latest | ||
- name: Install dependencies | ||
working-directory: ./server | ||
run: bun install | ||
- name: Run semantic-release | ||
id: semantic | ||
id: semantic | ||
working-directory: ./server | ||
env: | ||
HUSKY: 0 | ||
GITHUB_TOKEN: ${{ secrets.XYNE_GH_TOKEN }} | ||
GH_TOKEN: ${{ secrets.XYNE_GH_TOKEN }} | ||
run: bunx semantic-release --no-ci | ||
- name: Extract version from package.json | ||
id: get_version | ||
run: | | ||
VERSION=$(jq -r .version ./server/package.json) | ||
echo "Extracted version: $VERSION" | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.XYNE_DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.XYNE_DOCKERHUB_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
xynehq/staging:latest | ||
xynehq/staging:${{ steps.get_version.outputs.version }} |