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

Feature/mvd 5924 #277

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
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
81 changes: 45 additions & 36 deletions .github/workflows/build-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,56 @@ jobs:

check_changelog:
runs-on: ubuntu-latest
outputs:
was_updated: ${{ steps.check.outputs.was_updated }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
path: copy-repo
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
fetch-depth: 2

- name: Get changed files
id: changed-files
- name: Check if CHANGELOG.md was updated
id: check
run: |
cd copy-repo
if ${{ github.event_name == 'pull_request' }}; then
echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
else
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
fi

- name: List changed files
id: set-flag
run: |
cd copy-repo
for file in ${{ steps.changed-files.outputs.changed_files }}; do
echo "$file was changed"
if [[ $file == "CHANGELOG.md" ]]
then
echo "file-flag=true" >> $GITHUB_OUTPUT
break;
else
echo "file-flag=false" >> $GITHUB_OUTPUT
fi
done

- name: Check if CHANGELOG is Updated and Abort if not updated
if: steps.set-flag.outputs.file-flag != 'true'
if git diff --name-only HEAD^ HEAD | grep 'CHANGELOG.md'; then
echo "CHANGELOG.md was updated in the last commit."
echo "::set-output name=was_updated::true"
else
echo "CHANGELOG.md was NOT updated in the last commit."
echo "::set-output name=was_updated::false"
fi
- name: Check if CHANGELOG is Updated and if not updated pass to update_changelog
if: ${{ steps.check.outputs.was_updated != 'true' }}
run: |
echo "CHANGELOG.md not updated, please update CHANGELOG.md with the changes made in the pull request"
exit 1

- name: Remove copy-repo
if: always()
run: rm -r copy-repo

update_changelog:
needs: check_changelog
runs-on: ubuntu-latest
if: ${{ needs.check_changelog.outputs.was_updated == 'false' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Get commit message
run: echo "COMMIT_MESSAGE=$(git log --format=%B -n 1)" >> $GITHUB_ENV


- name: Append commit to Changelog
run: |
echo "CHANGELOG: $COMMIT_MESSAGE" >> CHANGELOG.md
echo "${{ steps.check-changelog.outputs.was_updated}}"

- name: Commit and push if it changed
run: |
git diff
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git commit -am "Update Changelog" -m "$COMMIT_MESSAGE" && echo ::set-output name=push::true || echo "No changes to commit"
git push origin || echo "No changes to push"

build:
runs-on: ubuntu-latest
needs: check-permission
Expand All @@ -103,7 +111,7 @@ jobs:
key: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-cache-node-modules-

- name: '[Prep 2] Setup Node'
uses: actions/setup-node@v2
with:
Expand Down Expand Up @@ -139,6 +147,7 @@ jobs:
pax-ssh-username: ${{ secrets.SSH_MARIST_USERNAME }}
pax-ssh-password: ${{ secrets.SSH_MARIST_RACF_PASSWORD }}
pax-name: zlux-core

- name: '[Prep 7] deploy'
uses: zowe-actions/zlux-builds/core/[email protected]/main

Loading