Skip to content

Commit

Permalink
fix: Change output dir (#19)
Browse files Browse the repository at this point in the history
chore: Change output directory structure to make copying files to repos easier
refactor branch exists to use gh cli
refactor: Change icons.dart to icons.g.dart
docs: Add comments to icons.g.dart
chore: Change output dir to web/flutter
test: Fix broken test

---------

Co-authored-by: zeta-icons-bot <[email protected]>
  • Loading branch information
thelukewalton and zeta-icons-bot authored Aug 20, 2024
1 parent 1346357 commit 6bc6f6d
Show file tree
Hide file tree
Showing 2,174 changed files with 179 additions and 6,080 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ jobs:
git push --set-upstream origin ${{steps.branch_name.outputs.BRANCH_NAME}} -f
- name: Check if PR exists
run: echo "pr_exists=$(gh pr list -H ${{steps.branch_name.outputs.BRANCH_NAME}} --json number -q length)" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Create Pull Request
if: ${{env.pr_exists == 0 && steps.fetch_icons.outputs.files_changed == 'true'}}
run: |
gh pr create -B main -H ${{steps.branch_name.outputs.BRANCH_NAME}} --title "${{steps.title.outputs.TITLE}}" --body 'Created by the Zeta Icons bot'
run: gh pr create -B main -H ${{steps.branch_name.outputs.BRANCH_NAME}} --title "${{steps.title.outputs.TITLE}}" --body 'Created by the Zeta Icons bot'
env:
GITHUB_TOKEN: ${{ github.token }}
87 changes: 87 additions & 0 deletions .github/workflows/copy-content.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Copy content to other repository

on:
workflow_call:
inputs:
repo:
required: true
type: string
branch:
required: true
type: string
source_dir:
required: true
type: string
destination_dir:
required: true
type: string
commit_msg:
required: true
type: string
secrets:
PAT:
required: true

jobs:
copy_content:
runs-on: ubuntu-latest
steps:
- name: Check if existing tokens branch exists
id: check_branch
env:
GH_TOKEN: ${{ secrets.PAT }}
run: echo "branch_exists=$(gh api repos/${{ inputs.repo }}/branches/${{ inputs.branch }} --jq '.name' | wc -l | xargs)" >> $GITHUB_OUTPUT
- name: Check if open PR exists
id: check_pr
env:
GH_TOKEN: ${{ secrets.PAT }}
run: echo "pr_exists=$(gh pr list -R ${{ inputs.repo }} -H ${{ inputs.branch }} --json number -q length)" >> $GITHUB_OUTPUT
- name: Checkout code
uses: actions/checkout@v4
- name: Pull latest changes
run: git pull
- name: Get current date
id: date
run: echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
- name: Push files if branch exists
uses: dmnemec/copy_file_to_another_repo_action@main
if: ${{ steps.check_branch.outputs.branch_exists != 0 }}
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
source_file: ${{ inputs.source_dir }}
destination_repo: ${{ inputs.repo }}
destination_folder: ${{ inputs.destination_dir }}
destination_branch: ${{ inputs.branch }}
user_email: "[email protected]"
user_name: "Zeta Tokens Bot"
commit_message: "deps(automated): ${{inputs.commit_msg}} ${{ steps.date.outputs.date }}"
- name: Push files if branch does not exist
uses: dmnemec/copy_file_to_another_repo_action@main
if: ${{ steps.check_branch.outputs.branch_exists == 0 }}
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
source_file: ${{ inputs.source_dir }}
destination_repo: ${{ inputs.repo }}
destination_folder: ${{ inputs.destination_dir }}
destination_branch_create: ${{ inputs.branch }}
user_email: "[email protected]"
user_name: "Zeta Tokens Bot"
commit_message: "deps(automated): ${{inputs.commit_msg}} ${{ steps.date.outputs.date }}"
- name: Open PR
uses: thecanadianroot/[email protected]
if: ${{ steps.check_pr.outputs.pr_exists == 0 }}
with:
token: ${{ secrets.PAT }}
base: main
head: ${{ inputs.branch }}
title: "deps(automated): ${{inputs.commit_msg}}"
labels: tokens
body: "${{inputs.commit_msg}} ${{ steps.date.outputs.date }}"
repository: ${{ inputs.repo }}
- name: Add comment to existing PR
env:
GH_TOKEN: ${{ secrets.PAT }}
if: ${{ steps.check_pr.outputs.pr_exists != 0 }}
run: gh pr comment -R ${{ inputs.repo }} ${{ inputs.branch }} --body "${{inputs.commit_msg}} ${{ steps.date.outputs.date }}"
94 changes: 8 additions & 86 deletions .github/workflows/update_zeta_flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,92 +9,14 @@ on:

env:
flutter_branch: update-zeta-icons
flutter_repo: ZebraDevs/zeta_flutter

jobs:
publish_flutter:
runs-on: ubuntu-latest
name: Commit and raise PR in Zeta Flutter
steps:
- name: Check if existing icons branch exists
run: echo "branch_exists=$(git ls-remote --heads https://github.com/${{env.flutter_repo}}.git refs/heads/${{env.flutter_branch}} | wc -l)" >> $GITHUB_ENV
- name: Check if open PR exists
run: echo "pr_exists=$(gh pr list -R ${{env.flutter_repo}} -H ${{env.flutter_branch}} --json number -q length)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
ref: ${{github.ref_name}}
- name: Get package version
id: package-version
uses: martinbeentjes/[email protected]
- name: Inject version
run: sed -i 's/VERSION_NUM/${{steps.package-version.outputs.current-version}}/g' outputs/definitions/icons.dart
- name: Push dart file to Zeta Flutter (branch exists)
uses: dmnemec/copy_file_to_another_repo_action@main
if: ${{env.branch_exists == 1}}
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
#TODO: pass file paths as inputs
source_file: "./outputs/definitions/icons.dart"
destination_repo: "${{env.flutter_repo}}"
destination_folder: "lib/src/assets"
destination_branch: "${{env.flutter_branch}}"
user_email: "[email protected]"
user_name: "zeta-icons-bot"
commit_message: "icons.dart"
- name: Push dart file to Zeta Flutter (branch does not exist)
if: ${{env.branch_exists == 0}}
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
#TODO: pass file paths as inputs
source_file: "./outputs/definitions/icons.dart"
destination_repo: "${{env.flutter_repo}}"
destination_folder: "lib/src/assets"
destination_branch_create: "${{env.flutter_branch}}"
user_email: "[email protected]"
user_name: "zeta-icons-bot"
commit_message: "icons.dart"
- name: Push round icon font file to Zeta Flutter
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
source_file: "./outputs/font/zeta-icons-round.ttf"
destination_repo: "${{env.flutter_repo}}"
destination_folder: "lib/src/assets/fonts"
destination_branch: "${{env.flutter_branch}}"
user_email: "[email protected]"
user_name: "zeta-icons-bot"
commit_message: "rounded font file"
- name: Push sharp icon font file to Zeta Flutter
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.PAT }}
with:
source_file: "./outputs/font/zeta-icons-sharp.ttf"
destination_repo: "${{env.flutter_repo}}"
destination_folder: "lib/src/assets/fonts"
destination_branch: "${{env.flutter_branch}}"
user_email: "[email protected]"
user_name: "zeta-icons-bot"
commit_message: "sharp font file"
- name: Create PR message
run: echo "pr_message=Updating to icons version ${{ steps.package-version.outputs.current-version }}" >> $GITHUB_ENV
- name: Open Zeta Flutter PR
uses: thecanadianroot/[email protected]
if: ${{env.pr_exists == 0}}
with:
token: ${{ secrets.PAT }}
base: main
head: ${{env.flutter_branch}}
title: "deps: Update zeta-icon library"
labels: icons
body: "${{env.pr_message}}"
repository: ${{env.flutter_repo}}
- name: Add comment to existing PR
if: ${{env.pr_exists != 0}}
run: gh pr comment -R ${{env.flutter_repo}} ${{env.flutter_branch}} --body '${{env.pr_message}}'
uses: ./.github/workflows/copy-content.yml
secrets: inherit
with:
repo: ZebraDevs/zeta_flutter
branch: "update-zeta-icons"
source_dir: "./outputs/dart/."
destination_dir: "lib/generated/icons"
commit_msg: "Update icons"
Loading

0 comments on commit 6bc6f6d

Please sign in to comment.