Skip to content

Get started with machine learning #23

Get started with machine learning

Get started with machine learning #23

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Reorder-on-Merge
# Controls when the workflow will run
on:
pull_request:
branches: [ "main" ]
types:
- closed
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-13
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- name: Check PR Status
run: |
if [ "${{ github.event.pull_request.merged }}" != "true" ]; then
echo "This PR isn't merged, so the action is quited."
curl \
-X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel"
fi
# Runs a set of commands using the runners shell
- name: Download the SwiftGGFormatter Tool
run: |
wget https://github.com/SwiftGGTeam/SwiftGGFormatter/releases/download/1.0.1/SwiftGGFormatter.zip
unzip ./SwiftGGFormatter.zip
chmod o+rwx ./SwiftGGFormatter.zip
- name: Fetch PR Info
id: pr_info
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
const ymlFiles = files.filter(file => file.filename.endsWith('.yml')).map(file => file.filename);
const result = ymlFiles.join(" ");
return result;
- name: Reorder
run: |
changedFiles=(${{ steps.pr_info.outputs.result }})
for file in $changedFiles; do
echo "Reorder: ./$file"
./SwiftGGFormatter "./$file"
git add "$file"
done
- name: Push to the Repo
run: |
git config user.name github-actions
git config user.email [email protected]
git commit -m "Auto Reformat"
git push