Skip to content

Merge pull request #12 from OpsGuild/dev #18

Merge pull request #12 from OpsGuild/dev

Merge pull request #12 from OpsGuild/dev #18

Workflow file for this run

name: Publish Jenkins Image
on:
push:
branches: [ main ]
tags: [ 'v*' ]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}},latest=true
type=semver,pattern={{major}}.{{minor}},latest=false
type=semver,pattern={{major}},latest=false
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && false }}
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.jenkins
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tag:
name: Update Major Version Tags
needs: publish
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update Major Tag
run: |
# Extract major version (e.g., v1 from v1.2.3)
MAJOR=$(echo "${{ github.ref_name }}" | cut -d. -f1)
echo "Updating major tag: $MAJOR to point to ${{ github.ref_name }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Force create/move major tag
git tag -f "$MAJOR" "${{ github.ref_name }}"
git push origin "$MAJOR" --force