-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract meta-repo code into
meta-repo-content-push
.
- Loading branch information
Showing
3 changed files
with
158 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
name: Push data to meta-repo | ||
|
||
inputs: | ||
META_CONTENT: | ||
required: true | ||
default: '' | ||
description: Data to put into `metafile.txt` | ||
META_REPO: | ||
required: true | ||
default: '' | ||
description: Target meta repo to sync metadata changes | ||
META_REPO_BRANCH: | ||
required: true | ||
default: '' | ||
description: Target meta repo branch name | ||
META_REPO_DEFAULT_BRANCH: | ||
required: false | ||
default: 'main' | ||
description: Target meta repo default branch name | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
|
||
- name: Encode '${{ inputs.META_REPO_BRANCH }}' and write to ENV | ||
id: encode-meta-repo-branch | ||
shell: bash | ||
run: | | ||
echo "META_REPO_BRANCH_B64=$(echo -n ${{ inputs.META_REPO_BRANCH }} | base64)" | tee -a "${GITHUB_ENV}" | ||
echo "meta-repo-branch-b64=$(echo -n ${{ inputs.META_REPO_BRANCH }} | base64)" | tee -a "${GITHUB_OUTPUT}" | ||
- name: Checkout metadata repo (${{ inputs.META_REPO_BRANCH }}) | ||
uses: actions/checkout@v4 | ||
id: meta-branch-exists | ||
continue-on-error: true | ||
with: | ||
repository: ${{ inputs.META_REPO }} | ||
ref: ${{ inputs.META_REPO_BRANCH }} | ||
token: ${{ env.GH_BOT_DEPLOY_TOKEN || github.token }} | ||
fetch-depth: 1 | ||
path: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
|
||
- name: Checkout metadata repo (${{ inputs.META_REPO_BRANCH }}) | ||
uses: actions/checkout@v4 | ||
if: steps.meta-branch-exists.outcome != 'success' | ||
with: | ||
repository: ${{ inputs.META_REPO }} | ||
ref: ${{ inputs.META_REPO_DEFAULT_BRANCH }} | ||
token: ${{ env.GH_BOT_DEPLOY_TOKEN || github.token }} | ||
fetch-depth: 1 | ||
path: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
clean: true | ||
|
||
- name: Create remote branch (${{ inputs.META_REPO_BRANCH }}) | ||
if: steps.meta-branch-exists.outcome != 'success' | ||
shell: bash | ||
working-directory: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
run: | | ||
git checkout -b ${{ inputs.META_REPO_BRANCH }} | ||
git push --set-upstream origin ${{ inputs.META_REPO_BRANCH }} | ||
- name: Push changes | ||
shell: bash | ||
working-directory: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
run: | | ||
git config --global user.email "[email protected]" && \ | ||
git config --global user.name "github-actions" | ||
echo "${{ inputs.META_CONTENT }}" | tee metafile.txt | ||
git status --porcelain | grep -q . || exit 0 | ||
git add -v metafile.txt && \ | ||
git commit --branch -m "update metadata" && \ | ||
git push --atomic -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,53 +183,23 @@ jobs: | |
environment: ${{ inputs.ENVIRONMENT }} | ||
steps: | ||
|
||
- name: Encode '${{ inputs.META_REPO_BRANCH }}' and write to ENV | ||
id: encode-meta-repo-branch | ||
shell: bash | ||
run: | | ||
echo "META_REPO_BRANCH_B64=$(echo -n ${{ inputs.META_REPO_BRANCH }} | base64)" | tee -a "${GITHUB_ENV}" | ||
echo "meta-repo-branch-b64=$(echo -n ${{ inputs.META_REPO_BRANCH }} | base64)" | tee -a "${GITHUB_OUTPUT}" | ||
- name: Checkout metadata repo (${{ inputs.META_REPO_BRANCH }}) | ||
- name: Checkout reusable actions | ||
uses: actions/checkout@v4 | ||
id: meta-branch-exists | ||
continue-on-error: true | ||
with: | ||
repository: ${{ inputs.META_REPO }} | ||
ref: ${{ inputs.META_REPO_BRANCH }} | ||
token: ${{ secrets.GH_BOT_DEPLOY_TOKEN || github.token }} | ||
repository: signalwire/actions-template | ||
ref: master | ||
fetch-depth: 1 | ||
path: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
path: actions | ||
sparse-checkout: | | ||
.github/actions/meta-repo/action.yml | ||
sparse-checkout-cone-mode: false | ||
|
||
- name: Checkout metadata repo (${{ inputs.META_REPO_BRANCH }}) | ||
uses: actions/checkout@v4 | ||
if: steps.meta-branch-exists.outcome != 'success' | ||
- name: Push build specific data to meta-repo | ||
uses: ./actions/.github/actions/meta-repo | ||
with: | ||
repository: ${{ inputs.META_REPO }} | ||
ref: ${{ inputs.META_REPO_DEFAULT_BRANCH }} | ||
token: ${{ secrets.GH_BOT_DEPLOY_TOKEN || github.token }} | ||
fetch-depth: 1 | ||
path: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
clean: true | ||
|
||
- name: Create remote branch (${{ inputs.META_REPO_BRANCH }}) | ||
if: steps.meta-branch-exists.outcome != 'success' | ||
working-directory: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
run: | | ||
git checkout -b ${{ inputs.META_REPO_BRANCH }} | ||
git push --set-upstream origin ${{ inputs.META_REPO_BRANCH }} | ||
- name: Push changes | ||
shell: bash | ||
working-directory: ${{ steps.encode-meta-repo-branch.outputs.meta-repo-branch-b64 }} | ||
run: | | ||
git config --global user.email "[email protected]" && \ | ||
git config --global user.name "github-actions" | ||
echo "${{ inputs.META_FILE_PATH_PREFIX }}" | tee metafile.txt | ||
git status --porcelain | grep -q . || exit 0 | ||
git add -v metafile.txt && \ | ||
git commit --branch -m "update metadata" && \ | ||
git push --atomic -v | ||
META_CONTENT: ${{ inputs.META_FILE_PATH_PREFIX }} | ||
META_REPO: ${{ inputs.META_REPO }} | ||
META_REPO_BRANCH: ${{ inputs.META_REPO_BRANCH }} | ||
META_REPO_DEFAULT_BRANCH: ${{ inputs.META_REPO_DEFAULT_BRANCH }} | ||
env: | ||
GH_BOT_DEPLOY_TOKEN: ${{ secrets.GH_BOT_DEPLOY_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Push data to meta-repo | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ENVIRONMENT: | ||
required: false | ||
type: string | ||
description: Environment where the variables and secrets are scoped to | ||
RUNNER: | ||
required: false | ||
default: ubuntu-latest | ||
description: A GitHub runner type | ||
type: string | ||
META_CONTENT: | ||
required: true | ||
type: string | ||
default: '' | ||
description: Data to put into `metafile.txt` | ||
META_REPO: | ||
required: true | ||
type: string | ||
default: '' | ||
description: Target meta repo to sync metadata changes | ||
META_REPO_BRANCH: | ||
required: true | ||
type: string | ||
default: '' | ||
description: Target meta repo branch name | ||
META_REPO_DEFAULT_BRANCH: | ||
required: false | ||
type: string | ||
default: 'main' | ||
description: Target meta repo default branch name | ||
|
||
secrets: | ||
GH_BOT_DEPLOY_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
meta-repo-content-push: | ||
runs-on: ${{ inputs.RUNNER }} | ||
permissions: | ||
contents: read | ||
id-token: write | ||
environment: ${{ inputs.ENVIRONMENT }} | ||
steps: | ||
|
||
- name: Checkout reusable actions | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: signalwire/actions-template | ||
ref: master | ||
fetch-depth: 1 | ||
path: actions | ||
sparse-checkout: | | ||
.github/actions/meta-repo/action.yml | ||
sparse-checkout-cone-mode: false | ||
|
||
- name: Push build specific data to meta-repo | ||
uses: ./actions/.github/actions/meta-repo | ||
with: | ||
META_CONTENT: ${{ inputs.META_CONTENT }} | ||
META_REPO: ${{ inputs.META_REPO }} | ||
META_REPO_BRANCH: ${{ inputs.META_REPO_BRANCH }} | ||
META_REPO_DEFAULT_BRANCH: ${{ inputs.META_REPO_DEFAULT_BRANCH }} | ||
env: | ||
GH_BOT_DEPLOY_TOKEN: ${{ secrets.GH_BOT_DEPLOY_TOKEN }} |