Skip to content

Commit

Permalink
Create publish-image.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
beliaev-maksim authored Jul 29, 2024
1 parent 7a36fb6 commit c5f0ba5
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/publish-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Publish Docker Image

on:
push:
tags:
- '*.*.*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract tag
id: extract_tag
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Verify SemVer format
id: semver_check
run: |
if [[ ! "${TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Tag ${TAG} is not in semver format X.X.X"
exit 1
fi
- name: Build Docker image
run: |
sudo docker buildx build -t github_jira_sync_app --output type=docker .
- name: Tag Docker image
run: |
sudo docker tag github_jira_sync_app ghcr.io/canonical/gh-jira-sync-bot:${TAG}
- name: Push Docker image
run: |
sudo docker push ghcr.io/canonical/gh-jira-sync-bot:${TAG}

0 comments on commit c5f0ba5

Please sign in to comment.