Skip to content

[Scale]: h350 d350

[Scale]: h350 d350 #27

name: Handle new scale issue
on:
issues:
types: [ "opened", "edited" ]
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/levelmeter
jobs:
process-issue:
if: contains(github.event.issue.labels.*.name, 'automatic-scale-request')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get Issue ID
id: issue_id
run: echo "id=${{ github.event.issue.number }}" >> $GITHUB_OUTPUT
- name: Parse Issue
id: parse-issue
uses: edumserrano/github-issue-forms-parser@v1
with:
template-filepath: '.github/ISSUE_TEMPLATE/new-scale-request.yml'
issue-form-body: '${{ github.event.issue.body }}'
- name: Parse issue body and extract fields
id: parse_fields
run: |
issue_body='${{ steps.parse-issue.outputs.parsed-issue }}'
CONTAINER_FORM=$(echo "$issue_body" | jq -r .containerForm)
LENGTH_UNIT=$(echo "$issue_body" | jq -r .lengthUnit)
VOLUME_UNIT=$(echo "$issue_body" | jq -r .volumeUnit)
DIAMETER=$(echo "$issue_body" | jq -r .diameter)
HEIGHT=$(echo "$issue_body" | jq -r .height)
MIN_VOLUME=$(echo "$issue_body" | jq -r .minVolume)
MAX_VOLUME=$(echo "$issue_body" | jq -r .maxVolume)
DESCRIPTION=$(echo "$issue_body" | jq -r .description)
FILENAME="${CONTAINER_FORM}_${LENGTH_UNIT}_d${DIAMETER}_h${HEIGHT}_${MIN_VOLUME}-${MAX_VOLUME}${VOLUME_UNIT}_i1"
DEFINITION_FILE="scales/definitions/$FILENAME.json"
VECTOR_FILE="scales/svgs/$FILENAME.svg"
echo "Form: $CONTAINER_FORM"
echo "LengthUnit: $LENGTH_UNIT"
echo "VolumeUnit: $VOLUME_UNIT"
echo "Diameter: $DIAMETER"
echo "Height: $HEIGHT"
echo "MinVolume: $MIN_VOLUME"
echo "MaxVolume: $MAX_VOLUME"
echo "Description: $DESCRIPTION"
echo "FileName: $FILENAME"
echo "Definition: $DEFINITION_FILE"
echo "SVG: $VECTOR_FILE"
echo "container_form=$CONTAINER_FORM" >> $GITHUB_OUTPUT
echo "length_unit=$LENGTH_UNIT" >> $GITHUB_OUTPUT
echo "volume_unit=$VOLUME_UNIT" >> $GITHUB_OUTPUT
echo "diameter=$DIAMETER" >> $GITHUB_OUTPUT
echo "height=$HEIGHT" >> $GITHUB_OUTPUT
echo "min_volume=$MIN_VOLUME" >> $GITHUB_OUTPUT
echo "max_volume=$MAX_VOLUME" >> $GITHUB_OUTPUT
echo "description=$DESCRIPTION" >> $GITHUB_OUTPUT
echo "filename=$FILENAME" >> $GITHUB_OUTPUT
echo "definition_file=$DEFINITION_FILE" >> $GITHUB_OUTPUT
echo "vector_file=$VECTOR_FILE" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create or override scale file
run: |
newFile="${{ steps.parse_fields.outputs.definition_file }}"
cp -f ./scales/definitions/_newscale.json.template "$newFile"
./scales/definitions/_apply_filename_to_json.sh "$newFile"
- name: Generate scale svg
run: |
docker run --rm -v $(pwd):/config $IMAGE_NAME -c /config/${{ steps.parse_fields.outputs.definition_file }}
- name: Configure git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "Add/Edit scale for scale request #${{ steps.issue_id.outputs.id }}"
committer: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
body: |
Create new scale for request #${{ steps.issue_id.outputs.id }}
title: '[Scale] Create new scale for request #${{ steps.issue_id_outputs.id }}'
labels: automatic-scale-request
branch: feature/scale-request-${{ steps.issue_id.outputs.id }}
add-paths: |
scales/**/*.json
scales/**/*.svg