-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Heba Elayoty <[email protected]>
- Loading branch information
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
name: Create, Scan and Publish KDM image | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Push image to MCR | ||
on: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: [ "Create release" ] | ||
types: [ completed ] | ||
branches: [ main, release-** ] | ||
|
||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
publish: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: pwsh | ||
steps: | ||
- name: Download tag artifact | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.KDM_ACCESS_TOKEN_READ }} | ||
script: | | ||
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: context.payload.workflow_run.id, | ||
}); | ||
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "artifacts" | ||
})[0]; | ||
let download = await github.rest.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
let fs = require('fs'); | ||
fs.writeFileSync(`/tmp/artifacts.zip`, Buffer.from(download.data)); | ||
- run: | | ||
mkdir -p /tmp/artifacts | ||
unzip /tmp/artifacts.zip -d /tmp/artifacts | ||
shell: bash | ||
- run: | | ||
echo "Downloaded artifacts:" | ||
ls -ablh /tmp/artifacts | ||
shell: bash | ||
- name: Parse artifacts and assign GA environment variables | ||
run: | | ||
tag=$(tail -n 1 /tmp/artifacts/tag.txt) | ||
echo "IMG_TAG=$tag" >> $GITHUB_ENV | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: true | ||
ref: ${{ env.IMG_TAG }} | ||
- name: 'Az CLI login' | ||
uses: azure/[email protected] | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
- name: 'Publish to ACR' | ||
id: publish | ||
run: | | ||
az acr login -n ${{ vars.AZURE_MCR_REGISTRY }} | ||
OUTPUT_TYPE=type=registry make docker-build-kdm | ||
env: | ||
VERSION: ${{ env.IMG_TAG }} | ||
REGISTRY: ${{ secrets.AZURE_MCR_REGISTRY }} |