Merge pull request #2432 from tawoe/develop-fix-actions

fix github action artifact download
This commit is contained in:
tesobe-daniel 2024-11-04 21:39:22 +01:00 committed by GitHub
commit b3a0844def
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 106 deletions

View File

@ -23,10 +23,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
uses: actions/github-script@v7
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
@ -34,7 +34,7 @@ jobs:
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "push"
})[0];
var download = await github.actions.downloadArtifact({
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,

View File

@ -24,10 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
uses: actions/github-script@v7
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
@ -35,7 +35,7 @@ jobs:
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "push"
})[0];
var download = await github.actions.downloadArtifact({
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,

View File

@ -21,10 +21,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
uses: actions/github-script@v7
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
@ -32,7 +32,7 @@ jobs:
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.actions.downloadArtifact({
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,

View File

@ -1,96 +0,0 @@
name: Build and publish jmx container develop
# read-write repo token
# access to secrets
on: workflow_dispatch
env:
## Sets environment variable
DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }}
DOCKER_HUB_REPOSITORY: obp-api
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
var matchRun = workflowRuns.data.workflow_runs.filter((run) => {
return run.head_sha == context.sha
var workflowRuns = await github.actions.listWorkflowRunsForRepo({
})[0];
owner: context.repo.owner,
repo: context.repo.repo,
});
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
var matchRun = workflowRuns.data.workflow_runs.filter((run) => {
return run.head_sha == context.sha
})[0];
run_id: matchRun.id,
});
if (!matchRun) {
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
console.log('No matching workflow run found for this commit');
return;
}
return artifact.name == "push"
})[0];
var artifacts = await github.actions.listWorkflowRunArtifacts({
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
owner: context.repo.owner,
repo: context.repo.repo,
run_id: matchRun.id,
artifact_id: matchArtifact.id,
});
archive_format: 'zip',
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
var fs = require('fs');
return artifact.name == "push"
})[0];
if (!matchArtifact) {
fs.writeFileSync('${{github.workspace}}/push.zip', Buffer.from(download.data));
- run: unzip push.zip
- name: prepare the artifact
run: |
mkdir -p obp-api/target/
cp push/obp-api-1.*.war obp-api/target/obp-api-1.10.1.war
- name: Build the Docker image
run: |
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin docker.io
docker build . --file .github/Dockerfile_PreBuild --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest --tag docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop
docker push docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }} --all-tags
echo docker done
- uses: sigstore/cosign-installer@main
- name: Write signing key to disk (only needed for `cosign sign --key`)
run: echo "${{ secrets.COSIGN_PRIVATE_KEY }}" > cosign.key
- name: Sign container image
run: |
cosign sign -y --key cosign.key \
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop
cosign sign -y --key cosign.key \
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest
cosign sign -y --key cosign.key \
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:$GITHUB_SHA
cosign sign -y --key cosign.key \
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:develop-OC
cosign sign -y --key cosign.key \
docker.io/${{ env.DOCKER_HUB_ORGANIZATION }}/${{ env.DOCKER_HUB_REPOSITORY }}:latest-OC
env:
COSIGN_PASSWORD: "${{secrets.COSIGN_PASSWORD}}"

View File

@ -80,7 +80,7 @@ jobs:
mkdir -p ./pr
echo ${{ github.event.pull_request.user.login }} > ./pr/UN
cp obp-api/target/obp-api-1.10.1.war ./pr/obp-api-1.10.1.war
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: pr
path: pr/