Skip to content

Commit

Permalink
Merge pull request #39 from leanix/feature/CID-3008/Publish-Image-to-…
Browse files Browse the repository at this point in the history
…OSS-Store-Docker-registry

CID-3008: running release drafter and tag next version of merge to ma…
  • Loading branch information
mohamedlajmileanix authored Nov 12, 2024
2 parents c9731b9 + 0da8392 commit f2c551e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/publish-dev-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,39 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Tag next version
id: tag-action
uses: K-Phoen/semver-release-action@master
with:
release_branch: main
release_strategy: tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Release Draft
uses: actions/[email protected]
if: (steps.tag-action.outputs.tag != '')
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const tag = "${{ steps.tag-action.outputs.tag }}";
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
const draftRelease = releases.find(release => release.tag_name === tag && release.draft === true);
if (!draftRelease) {
console.log(`No draft release found for tag ${tag}`);
return;
}
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: draftRelease.id,
draft: false
});
console.log(`Published draft release for tag ${tag}`);
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand Down
41 changes: 8 additions & 33 deletions .github/workflows/publish-package-to-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,13 @@ jobs:
environment: ghcr:leanix-github-agent

steps:
- name: Tag next version
id: tag-action
uses: K-Phoen/semver-release-action@master
with:
release_branch: main
release_strategy: tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Release Draft
uses: actions/[email protected]
if: (steps.tag-action.outputs.tag != '')
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const tag = "${{ steps.tag-action.outputs.tag }}";
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
const draftRelease = releases.find(release => release.tag_name === tag && release.draft === true);
if (!draftRelease) {
console.log(`No draft release found for tag ${tag}`);
return;
}
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: draftRelease.id,
draft: false
});
console.log(`Published draft release for tag ${tag}`);
- name: Extract Docker image tag
id: extract_tag
run: |
TAG=${GITHUB_REF#refs/tags/}
CLEAN_TAG=${TAG//[^0-9.]/}
echo "Docker image tag: ${CLEAN_TAG}"
echo "::set-output name=tag::${CLEAN_TAG}"
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -92,7 +67,7 @@ jobs:
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag-action.outputs.tag }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.extract_tag.outputs.tag }}
labels: ${{ steps.meta.outputs.labels }}

- name: Generate artifact attestation
Expand Down

0 comments on commit f2c551e

Please sign in to comment.