Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
prace-lessons
Lesson Template
Commits
75c991e6
Commit
75c991e6
authored
10 years ago
by
Greg Wilson
Browse files
Options
Downloads
Plain Diff
Merge pull request #18 from r-gaia-cs/add-script-for-label
Add small script to setup label in lesson repo
parents
d2f6588a
d872877a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/setup-labels
+67
-0
67 additions, 0 deletions
tools/setup-labels
with
67 additions
and
0 deletions
tools/setup-labels
0 → 100755
+
67
−
0
View file @
75c991e6
#!/bin/bash
#
## This script sets up labels for issues in your GitHub repository.
##
## Syntax:
##
## $ tools/setup-label OWNER REPO
##
## Parameters:
##
## - OWNER: GitHub username of the owner of the repository
## - REPO: the name of the repository
##
## Example:
##
## For set up the labels at https://github.com/wking/swc-modular-shell use
##
## $ tools/setup-label wking swc-modular-shell
if
test
$#
-lt
2
then
echo
"Missing parameters."
echo
grep
'^##'
tools/setup-labels |
sed
's/## //'
|
sed
's/##//'
exit
1
fi
OWNER
=
$1
REPO
=
$2
GITHUB_URL
=
https://github.com/
${
OWNER
}
/
${
REPO
}
LABELS
=(
getting-started working-in-progress discussion
)
COLORS
=(
fbca04 f7c6c7 5319e7
)
# Test if repository exists
curl
-s
--head
${
GITHUB_URL
}
|
head
-n
1 |
grep
-q
"HTTP/1.[01] [23].."
if
test
$?
-ne
0
then
echo
"ERROR: this repository doesn't exist"
exit
$?
fi
echo
"Before setup the labels for
${
GITHUB_URL
}
"
echo
"you must provide some informations."
echo
"Your GitHub username:"
read
USERNAME
echo
"Your GitHub password:"
read
-s
PASSWORD
# Create labels
for
INDEX
in
$(
seq
1
${#
LABELS
[*]
}
)
do
curl
-s
-f
-X
POST
\
-u
${
USERNAME
}
:
${
PASSWORD
}
\
-d
"{
\"
name
\"
:
\"
${
LABELS
[
${
INDEX
}
]
}
\"
,
\"
color
\"
:
\"
${
COLORS
[
${
INDEX
}
]
}
\"
}"
\
"https://api.github.com/repos/
${
OWNER
}
/
${
REPO
}
/labels"
>
/dev/null
if
test
$?
-ne
0
then
echo
"Failed when trying to create the label
${
LABELS
[
${
INDEX
}
]
}
."
echo
"Probably the label
${
LABELS
[
${
INDEX
}
]
}
already exists."
echo
"Please check at
${
GITHUB_URL
}
/labels or run"
echo
echo
"
$
curl -X POST -u
${
USERNAME
}
-d
\"
{
\"
name
\"
:
\"
${
LABELS
[
${
INDEX
}
]
}
\"
,
\"
color
\"
:
\"
${
COLORS
[
${
INDEX
}
]
}
\"
}
\"
\"
https://api.github.com/repos/
${
OWNER
}
/
${
REPO
}
/labels
\"
"
echo
echo
"to get more information of the error. If you find a bug"
echo
"report it at https://github.com/swcarpentry/lesson-template/."
fi
done
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment