Skip to content

Commit

Permalink
!Refactoring (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
iletai authored May 4, 2024
1 parent b9ec22b commit 561b2f0
Show file tree
Hide file tree
Showing 12 changed files with 509 additions and 152 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/issues_tracker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Tracker Issues CalendarView.

on:
issues:
types: [opened, edited]

jobs:
example_gemini:
name: Example Usable
runs-on: macos-latest
steps:
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"

- name: Cache yarn dependencies
id: checkout
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: '~/.npm'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install NPM dependencies
run: npm i @google/generative-ai

- name: Using Scripts
id: scriptgemini
uses: actions/github-script@v7
continue-on-error: true
env:
APIKEY: ${{ secrets.GEMINI_API_KEY }}
with:
script: |
const modelName = {
model: ["gemini-pro"],
generationConfig: { temperature: 0 },
};
const { GenerativeModel } = require("@google/generative-ai");
const model = new GenerativeModel(process.env.APIKEY, modelName);
const { data: availableLabels } = await github.rest.issues.listLabelsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
});
const prompt = `
You have a role to manage a GitHub repository. Given an issue information (subject and body), choose suitable labels to it from the labels available for the repository.
Use the following format:
LABELS: "the names of the chosen labels, each name must not be surrounded double quotes, separated by a comma"
Only use the following labels:
\`\`\`
${availableLabels.map((label) => label.name).join(", ")}
\`\`\`
## ISSUE ##
SUBJECT: ${context.payload.issue.title}
BODY: ${context.payload.issue.body}
`;
const result = await model.generateContent(prompt);
const labels = /LABELS\: (.+)/g.exec(result.response.text());
const label = labels[1].trim().split(/,\s*/);
console.log(label);
return label
- name: Add Labels
uses: actions/github-script@v7
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
RESULT_GEMINI: ${{ steps.scriptgemini.outputs.result }}
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: `The labels are ${JSON.parse(process.env.RESULT_GEMINI)}`
});
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: JSON.parse(process.env.RESULT_GEMINI)
});
4 changes: 2 additions & 2 deletions CalendarExampleView/CalendarExampleView/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct ContentView: View {
}, headerView: { date in
HStack {
ForEach(date, id: \.self) {
Text($0.weekDayShortName)
Text($0.weekDayShortName.uppercased())
.font(.footnote)
.fontWeight(.bold)
.foregroundColor(
Expand All @@ -53,7 +53,7 @@ struct ContentView: View {
.font(.footnote)
.fontWeight(.semibold)
.foregroundColor(
Calendar.current.isDateInWeekend(date) ? .red : .gray
Calendar.current.isDateInWeekend(date) ? .red.opacity(0.4) : .gray
)
}
.frameInfinity()
Expand Down
Loading

0 comments on commit 561b2f0

Please sign in to comment.