ubiquity / ts-template

A template repository for all @ubiquity projects.
2 stars 24 forks source link

Add a Github Actions script that synchronizes the template every month. #56

Closed zyrafal closed 2 months ago

zyrafal commented 3 months ago

Resolves #54

The script is located in .github/workflows/sync.yml and it synchronizes the template at 0:00 UTC the 1st day of every month.

I cloned a branch called "test/cd", which was 128 commits behind the "development" branch, into a new branch called "testing", and then I successfuly ran the script on it, proving that it works.

0x4007 commented 3 months ago

Can you show your test branch results? Once you proved this works, the second part of the task is to update all of the recently updated repositories with the script as well.

ubiquity-os-deployer[bot] commented 3 months ago
0e9b021
89a8e54
b5235dc
89b942e
d08a54e
gentlementlegen commented 3 months ago

Doesn't this directly merge in the content instead of opening a pull-request? I think it would be less error prone to open a PR against the repo instead of directly merging the changes, so we can double check before they get in the repo, which is also in the spec.

zyrafal commented 3 months ago

Okay, the sync.yml script now creates a pull request.

Here is a pull request on the "testing" branch cloned from "test/cd": https://github.com/zyrafal/ts-template/pull/1

And on the "testing-2" branch I merged the pull request: https://github.com/zyrafal/ts-template/tree/testing-2

However, I haven't yet managed to get the other script to work, I'm still working on it.

zyrafal commented 3 months ago

I didn't manage to get the script that adds it to every repo working as a Github Action, but it works when you run it in shell:

git clone https://github.com/zyrafal/ts-template
cd ts-template/

sync_path=$(realpath .github/workflows/sync-template.yml)
original_remote=$(git remote get-url origin)
# repos=$(gh repo list ubiquity --limit 1 --json name,updatedAt -q '.[] | select(.updatedAt > (now - 30*24*60*60)) | .name')
repos=work.ubq.fi pay.ubq.fi ubiquibot-logger devpool-directory onboard.ubq.fi rpc-handler ubiquibot-telegram ubiquibot-kernel uusd.ubq.fi ubiquity-dollar safe.ubq.fi cloudflare-deploy-action series-a webauthn-evm-signing-key .github ubq.fi ubiquibot leaderboard.ubq.fi uad-contracts business-development keygen.ubq.fi audit.ubq.fi ubiquibot-logging test-cf-deploy hackbar research recruiting faucet card-issuance nft-rewards github-labels-processor scraper-kernel foundry-storage-check foundry-storage-check-nonfork ubiquibar config-hunter sponsorships action-conventional-commits gnosischain.world devpool-directory-bounties uniswap-v3-liquidity-provider-indicator tiny-bonds ubiquiverse-landing-page ubiquity-instadapp the-ubiquity-stick dsa-connect assembly simple-bond dsa-resolvers dsa-connectors olympus-contracts launch-party vfat-tools land-dao-admin-ui nft-contracts web3-ui-dynamic uad-ui-prototyping uad-debt-contracts-prototyping uad-bonding-contracts-prototyping uad-common-contracts-prototyping
for REPO in $repos; do
    gh repo fork --clone ubiquity/$repo
    cd $repo
    mkdir -p .github/workflows
    cp $sync_path .github/workflows/sync-template.yml
    git add .github/workflows/sync-template.yml
    git commit -m "Add sync-template.yml workflow"
    git push
    gh pr create --title "Add sync-template.yml workflow that synchronizes the template every month" --body "Details: https://github.com/ubiquity/ts-template/issues/54" --base development
        cd ..
        rm -rf $repo

Also, I created a new repository with the template and successfuly ran the sync script there (though there were no changes that needed to by synced): https://github.com/zyrafal/test-repo/pull/1

gentlementlegen commented 2 months ago

@zyrafal I tried on my own org, and it seems to crash if there are conflicts during the process, see the logs. Maybe creating an orphan branch would solve this problem.

zyrafal commented 2 months ago

Okay, I think it works now.

gentlementlegen commented 2 months ago

The workflow seemed to work: https://github.com/Meniole/command-start-stop/pull/11

It just doesn't seem super easy to use because I would have many files to delete, since the template covers a lot of cases. I Wonder if we could add some configuration values to ignore certain files (the README for example) dynamically.

0x4007 commented 2 months ago

The workflow seemed to work: https://github.com/Meniole/command-start-stop/pull/11

Can you get it to auth as our bot like in our other ci

zyrafal commented 2 months ago

Done.

gentlementlegen commented 2 months ago

The workflow seemed to work: Meniole/command-start-stop#11

Can you get it to auth as our bot like in our other ci

This requires every repo to have our credentials stored because this comes from an automated workflow and doesn't get the credentials from the kernel, I don't think that's very practical.

0x4007 commented 2 months ago

Every repo has our credentials stored. It's an org secret.

0x4007 commented 2 months ago

Before accepting this pull and paying out the reward, please open pulls to the other active repositories as per the spec.

Ensure that they link to the issue so we can track all of them. Thank you!