From 6648659694dac6281446fb38b8abe98d1a8179ee Mon Sep 17 00:00:00 2001 From: Andrew Whitfield Date: Wed, 24 Apr 2024 15:47:35 +0100 Subject: [PATCH] Add actions --- .github/workflows/update-internal-repo.yaml | 39 ++++++++++++++++++++ build/bin/copy-gitops.sh | 41 +++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 .github/workflows/update-internal-repo.yaml create mode 100755 build/bin/copy-gitops.sh diff --git a/.github/workflows/update-internal-repo.yaml b/.github/workflows/update-internal-repo.yaml new file mode 100644 index 000000000..fd723d706 --- /dev/null +++ b/.github/workflows/update-internal-repo.yaml @@ -0,0 +1,39 @@ +name: Update Internal GHE Repo +on: + push: + branches: + - '**' + tags-ignore: + - '**' +jobs: + update-repo: + runs-on: ubuntu-latest + steps: + - name: Checkout local repo + uses: actions/checkout@v4 + with: + path: source + + - name: Checkout remote repo + uses: actions/checkout@v4 + with: + github-server-url: https://github.ibm.com + repository: automation-paas-cd-pipeline/mas-gitops + ref: ${GITHUB_REF##*/} + token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} + path: target + + - name: Copy over files + run: $GITHUB_WORKSPACE/build/bin/copy-gitops.sh -s $GITHUB_WORKSPACE/source -t $GITHUB_WORKSPACE/target + + - name: Setup git config + run: | + cd $GITHUB_WORKSPACE/target + git config user.name "GitHub Actions Bot" + git config user.email "<>" + + - name: Commit changes to remote repo + run: | + echo "Push changes to ${GITHUB_REF##*/} branch of https://github.ibm.com/automation-paas-cd-pipeline/mas-gitops" + git push origin ${GITHUB_REF##*/} + \ No newline at end of file diff --git a/build/bin/copy-gitops.sh b/build/bin/copy-gitops.sh new file mode 100755 index 000000000..0bcb52fa2 --- /dev/null +++ b/build/bin/copy-gitops.sh @@ -0,0 +1,41 @@ +#/bin/bash + +echo "build/bin/copy-gitops.sh -s -t " +echo "" +echo "Example usage: " +echo " build/bin/copy-gitops.sh -s /Users/whitfiea/Work/Git/ibm-mas/gitops -t /Users/whitfiea/Work/Git/ibm-mas/mas-gitops" +echo "" + +# Process command line arguments +while [[ $# -gt 0 ]] +do + key="$1" + shift + case $key in + -s|--source) + SOURCE=$1 + shift + ;; + + -t|--target) + TARGET=$1 + shift + ;; + + *) + # unknown option + echo -e "\nUsage Error: Unsupported flag \"${key}\"\n\n" + exit 1 + ;; + esac +done + +: ${SOURCE?"Need to set -s|--source argument for source directory"} +: ${TARGET?"Need to set -t|--target argument for target directory"} + +echo "Copying gitops" +cp -vr ${SOURCE}/applications/* ${TARGET}/applications/ +cp -vr ${SOURCE}/root-applications/* ${TARGET}/root-applications/ +cp -vr ${SOURCE}/docs/* ${TARGET}/docs/ +cp -vr ${SOURCE}/README.md* ${TARGET}/README.md +cp -vr ${SOURCE}/LICENSE ${TARGET}/LICENSE