Skip to content

Commit

Permalink
Rename to deploy-ci-artifact
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Heinrich <[email protected]>
  • Loading branch information
andistorm committed Sep 10, 2024
1 parent 5cc45cc commit fdb2c0b
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 63 deletions.
50 changes: 47 additions & 3 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ on:
required: false
default: 'build/gcovr-coverage'
type: string
coverage_xml_path:
description: 'The path to the coverage xml, relative to the github workspace'
required: false
default: 'build/coverage.xml'
type: string
coverage_deploy_target_repo:
description: 'The repository to deploy the coverage report to'
required: true
Expand Down Expand Up @@ -148,6 +153,11 @@ on:
required: false
default: 'true'
type: string
run_coverage_badge_creation:
description: 'Run coverage badge creation'
required: false
default: '${{ inputs.run_coverage == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}'
type: string
run_install:
description: 'Run install'
required: false
Expand Down Expand Up @@ -298,16 +308,23 @@ jobs:
if-no-files-found: error
name: coverage-report
path: ${{ inputs.coverage_report_path }}
- name: Archive coverage xml
if: ${{ steps.run_coverage.outcome == 'success' || steps.run_coverage.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: coverage-xml
path: ${{ inputs.coverage_xml_path}}
- name: Deploy html coverage report
id: deploy_coverage_report
if: ${{ steps.run_coverage.outcome == 'success' || steps.run_coverage.outcome == 'failure' }}
# LTODO update tag
uses: everest/everest-ci/github-actions/deploy-ci-logs@feature/add-reusable-ci-workflow
uses: everest/everest-ci/github-actions/deploy-ci-artifact@feature/add-reusable-ci-workflow
with:
target_repo: ${{ inputs.coverage_deploy_target_repo }}
target_logs_name: coverage-report
logs_dir: ${{ inputs.coverage_report_path }}
github_token: ${{ secrets.coverage_deploy_token }}
artifact_name: coverage-report
artifact_directory: ${{ inputs.coverage_report_path }}
- name: Write summary coverage
if: ${{ steps.run_coverage.outcome == 'success' || steps.run_coverage.outcome == 'failure' }}
run: |
Expand Down Expand Up @@ -413,3 +430,30 @@ jobs:
display-options: fEX
fail-on-empty: True
title: Test results
create_coverage_badge:
name: Create Coverage Badge
needs:
- build
runs-on: ${{ inputs.runner }}
if: ${{ inputs.run_coverage_badge_creation == 'true' }}
steps:
- name: Download coverage report
uses: actions/[email protected]
with:
if-no-files-found: error
name: coverage-xml
path: coverage-xml
- name: Generate coverage badge
run: |
# LTODO install in docker image
pip install genbadge[all]
mkdir -p ${{ github.workspace }}/coverage-badge/
genbadge -i ${{ github.workspace }}/coverage-xml/gcovr-coverage-xml.xml -o ${{ github.workspace }}/coverage-badge/coverage-badge.svg -n "Coverage" --local -v
- name: Deploy coverage badge
# LTODO update version
uses: everest/everest-ci/github-actions/deploy-ci-artifact@feature/add-reusable-ci-workflow
with:
target_repo: ${{ github.repository }}
github_token: ${{ secrets.SA_GITHUB_PAT }}
artifact_name: coverage-badge
artifact_directory: ${{ github.workspace }}/coverage-badge/
76 changes: 76 additions & 0 deletions github-actions/deploy-ci-artifact/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: 'Deploy CI Artifact'
description: 'Deploy CI artifact to a github pages repository'
inputs:
target_repo:
description: 'Repository to deploy artifact to'
required: true
github_token:
description: 'Github token, with write access to the target repository'
required: true
source_repo:
description: 'Repository to deploy artifact from'
required: true
default: ${{ github.repository }}
workflow_run_id:
description: 'Workflow run id to deploy logs from'
required: true
default: ${{ github.run_id }}
deploy_global_artifact:
description: 'Deploy global artifact, without workflow_run_id'
required: false
default: false
artifact_name:
description: 'Name of the artifact to deploy'
required: true
artifact_directory:
description: 'Directory or containing the artifact to deploy'
required: true
outputs:
deployed_path:
description: 'Path to the deployed logs'
value: ${{ steps.determine_target_path.outputs.target_path }}
runs:
using: "composite"
steps:
- name: Configure git
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "Github Service Account"
- name: Checkout target repository
uses: actions/[email protected]
with:
repository: ${{ inputs.target_repo }}
path: gh-pages-repo
token: ${{ inputs.github_token }}
ref: main
- name: Determine target path
id: determine_target_path
shell: bash
run: |
if [ "${{ inputs.deploy_global_artifact }}" = "true" ]; then
target_path="ci-artifacts/${{ inputs.source_repo }}/${{ inputs.artifact_name }}"
else
target_path="ci-artifacts/${{ inputs.source_repo }}/${{ inputs.workflow_run_id }}/${{ inputs.artifact_name }}"
fi
echo "target_path=$target_path" >> $GITHUB_OUTPUT
- name: Copy Artifact
shell: bash
run: |
mkdir -p gh-pages-repo/${{ steps.determine_target_path.outputs.target_path }}
if [ "${{ inputs.deploy_global_artifact }}" = "true" ]; then
rm -rf gh-pages-repo/${{ steps.determine_target_path.outputs.target_path }}/*
fi
cp -r ${{ inputs.artifact_directory }}/* gh-pages-repo/${{ steps.determine_target_path.outputs.target_path }}
- name: Commit and push logs
shell: bash
run: |
git add ${{ steps.determine_target_path.outputs.target_path }}
if [ "${{ inputs.deploy_global_artifact }}" = "true" ]; then
commit_message="Deploy global artifact and remove old one: ${{ inputs.source_repo }}/${{ inputs.artifact_name }}"
else
git commit -m "Deploy new artifact: ${{ inputs.source_repo }}/${{ inputs.workflow_run_id }}/${{ inputs.artifact_name }}"
fi
git commit -m "$commit_message"
git push
working-directory: gh-pages-repo
60 changes: 0 additions & 60 deletions github-actions/deploy-ci-logs/action.yaml

This file was deleted.

0 comments on commit fdb2c0b

Please sign in to comment.