Skip to content

Bump actions/upload-artifact from 3 to 4 (#30) #75

Bump actions/upload-artifact from 3 to 4 (#30)

Bump actions/upload-artifact from 3 to 4 (#30) #75

Workflow file for this run

on:
push:
branches:
- '*'
- '!badges'
jobs:
test:
runs-on: ubuntu-latest
name: A job to test this action
steps:
# Get current banch name to use it as dest directory
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> "${GITHUB_OUTPUT}"
id: extract_branch
- name: Prepare environment
id: coverage
run: |
# Generates a GitHub Workflow output named `lines` with a coverage value
echo "lines=${COVERAGE}" >> "${GITHUB_OUTPUT}"
# Output values to be used by other steps
echo "path=${BADGE_PATH}" >> "${GITHUB_OUTPUT}"
echo "branch=${BRANCH}" >> "${GITHUB_OUTPUT}"
env:
COVERAGE: 53.5%
BADGE_PATH: ${{ steps.extract_branch.outputs.branch }}/test-badge.svg
BRANCH: badges
- uses: actions/checkout@v4
with:
ref: ${{ steps.coverage.outputs.branch }}
# Create the directory where badges will be saved, if needed
- name: Create destination directory
env:
BADGE_PATH: ${{ steps.coverage.outputs.path }}
run: mkdir -p "${BADGE_PATH%/*}"
# Use the output from the `coverage` step
- name: Generate the badge SVG image
uses: emibcn/badge-action@v2.0.2
id: badge
with:
label: 'Test coverage'
status: ${{ steps.coverage.outputs.lines }}
color: 'blue,555,daf'
path: ${{ steps.coverage.outputs.path }}
- name: Upload badge as artifact
uses: actions/upload-artifact@v4
with:
name: badge
path: ${{ steps.coverage.outputs.path }}
if-no-files-found: error
- name: Commit badge
continue-on-error: true
env:
BADGE: ${{ steps.coverage.outputs.path }}
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add "${BADGE}"
git commit -m "Add/Update badge"
- name: Push badge commit
uses: ad-m/github-push-action@master
if: ${{ success() }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.coverage.outputs.branch }}