Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: open a PR on the celo-org/docs automagically #110

Merged
merged 30 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e9a6401
ci: first test
nicolasbrugneaux Jan 30, 2024
d5bf555
ci: add trigger on push on this branch only
nicolasbrugneaux Jan 30, 2024
d81adcc
fix: typo
nicolasbrugneaux Jan 30, 2024
65edfc7
fix: commit ref
nicolasbrugneaux Jan 30, 2024
18199c5
fix: submodule fetching?
nicolasbrugneaux Jan 30, 2024
57c4d94
fix: typo
nicolasbrugneaux Jan 31, 2024
aeb3cf1
fix: sha?
nicolasbrugneaux Jan 31, 2024
e0d3d74
ci: token?
nicolasbrugneaux Jan 31, 2024
2652572
ci: token?
nicolasbrugneaux Jan 31, 2024
e2ed249
adding docs token from akeyless
pputman-clabs Jan 31, 2024
0addc34
updating uses path
pputman-clabs Jan 31, 2024
6111f52
adding the necessary server url
pputman-clabs Jan 31, 2024
dadb9ea
Merge branch 'master' into ci/update-celo-docs
nicolasbrugneaux Jan 31, 2024
c87a0e2
ci: token?
nicolasbrugneaux Jan 31, 2024
fc2aabd
fix: repo
nicolasbrugneaux Jan 31, 2024
f77ec62
fix: branches
nicolasbrugneaux Jan 31, 2024
c46e5f2
fix: token usage?
nicolasbrugneaux Jan 31, 2024
90a4e32
fix: setup env differently
nicolasbrugneaux Jan 31, 2024
4489282
fix: use checkout action
nicolasbrugneaux Jan 31, 2024
b404621
fix: typo
nicolasbrugneaux Jan 31, 2024
dbb837e
fix: fetch all branches
nicolasbrugneaux Jan 31, 2024
17dc256
fix: fetch differently
nicolasbrugneaux Jan 31, 2024
65a17b9
fix: fetch
nicolasbrugneaux Jan 31, 2024
d5b8fe0
fix: fetch?
nicolasbrugneaux Jan 31, 2024
98a4ca3
fix: fetch??
nicolasbrugneaux Jan 31, 2024
0a6449a
fix: use ubuntu-latest in order to get gh
nicolasbrugneaux Jan 31, 2024
b239325
ci: better PR body
nicolasbrugneaux Jan 31, 2024
f29572f
fix: only create a PR when CLI is released
nicolasbrugneaux Jan 31, 2024
88a7d86
chore: use the script in the target repo
nicolasbrugneaux Feb 1, 2024
601367c
Merge branch 'master' into ci/update-celo-docs
nicolasbrugneaux Feb 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/open-docs-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
name: Open a pull-request on the celo-org/docs repository

on:
workflow_call:
inputs:
commit:
description: 'Commit of the developer-tooling repo that the submodule will be updated to'
type: string
required: true

workflow_dispatch:
inputs:
commit:
description: 'Commit of the developer-tooling repo that the submodule will be updated to'
type: string
required: true

jobs:
open-docs-pr:
name: Open a pull-request on the celo-org/docs repository
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
repository-projects: write
steps:
- name: Fetch secrets from AKeyless
id: fetch-secrets
uses: docker://us-west1-docker.pkg.dev/devopsre/akeyless-public/akeyless-action:latest
with:
access-id: p-kf9vjzruht6l
api-url: https://api.gateway.akeyless.celo-networks-dev.org
dynamic-secrets: '{"/dynamic-secrets/keys/github/docs/contents=write,pull_requests=write":"DOCS_TOKEN"}'

- name: Checkout Repo
uses: actions/checkout@v4
with:
repository: 'celo-org/docs'
submodules: 'recursive'
fetch-depth: 0
ref: main
token: ${{ env.DOCS_TOKEN }}

- name: Open pull-request
env:
COMMIT: ${{ inputs.commit }}
REPOSITORY: 'celo-org/docs'
DOCS_CWD: 'celo-docs'
BASE_BRANCH: main
NEW_BRANCH: 'ci/${{ github.run_id }}-${{ github.run_attempt }}'
BOT_NAME: 'github-actions'
BOT_EMAIL: 'github-actions@github.com'

run: |
set -x

# Setup the committers identity.
git config --global user.name $BOT_NAME
git config --global user.email $BOT_EMAIL

# Create a new feature branch for the changes.
git checkout -b $NEW_BRANCH

cd submodules/developer-tooling
git fetch --all
git checkout $COMMIT
cd ../..
./scripts/copy-generated-docs.sh

git status
git add submodules/developer-tooling
git add docs/cli
git commit -m "chore: update developer-tooling submodule"
git push origin $NEW_BRANCH

cat >/tmp/pr-body.md <<EOL
Update developer-tooling submodule to [$COMMIT](https://github.com/celo-org/developer-tooling/commit/$COMMIT).

Merging this pull-request will update the docs using generated files (such as the CLI docs).

🤖 _This pull-request was opened by a robot beep boop._ 🤖
EOL

echo "$DOCS_TOKEN" > token.txt
gh auth login --with-token < token.txt
gh pr create \
--body-file /tmp/pr-body.md \
--title "chore: update auto-generated docs reference from developer-tooling" \
--head "$NEW_BRANCH" \
--base "$BASE_BRANCH"
18 changes: 13 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ jobs:
id-token: write
pull-requests: write
repository-projects: write
outputs:
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Akeyless Get Secrets
id: get_auth_token
uses:
docker://us-west1-docker.pkg.dev/devopsre/akeyless-public/akeyless-action:latest
uses: docker://us-west1-docker.pkg.dev/devopsre/akeyless-public/akeyless-action:latest
with:
api-url: https://api.gateway.akeyless.celo-networks-dev.org
access-id: p-kf9vjzruht6l
Expand All @@ -34,8 +35,8 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: "enable corepack for yarn"
run : sudo corepack enable yarn
- name: 'enable corepack for yarn'
run: sudo corepack enable yarn
shell: bash
# must call twice because of chicken and egg problem with yarn and node
- uses: actions/setup-node@v4
Expand All @@ -54,4 +55,11 @@ jobs:
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
version: yarn version-and-reinstall
version: yarn version-and-reinstall

open-docs-pr:
needs: release
if: ${{ contains(fromJson(needs.release.outputs.publishedPackages).*.name, '@celo/cli') }}
uses: celo-org/developer-tooling/.github/workflows/open-docs-pr.yml@main
with:
commit: ${{ github.sha }}
Loading