Do not fail CI for appropriately skipped branch #121
Workflow file for this run
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
name: "Smoke tests" | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- .github/workflows/test-action.yml | |
permissions: | |
contents: write | |
actions: write | |
jobs: | |
generate_info: | |
name: "Generate dependency information" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go environment | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: "Generate dependency information" | |
shell: bash | |
env: | |
APPLICATION: go-mkopensource | |
APPLICATION_TYPE: internal | |
BUILD_HOME: '.' | |
BUILD_TMP: '${{ runner.temp }}/license' | |
SCRIPTS_HOME: '.' | |
GIT_TOKEN: ${{ github.token }} | |
NODE_IMAGE: 'node:14.13.1-alpine' | |
run: | | |
# Commit dummy license files | |
: > DEPENDENCY_LICENSES.md | |
: > DEPENDENCIES.md | |
git add DEPENDENCY_LICENSES.md DEPENDENCIES.md | |
# Generate license information | |
export GO_IMAGE=$(grep -e 'FROM golang:' "build-aux/docker/go_builder.dockerfile" | cut -d ' ' -f2 ) | |
#Copy test data to another folder since it can't be used from there | |
cp -a ./test-data ./ui | |
export NPM_PACKAGES=$( echo -e "./ui/package.json\n./ui/package-lock.json" ) | |
mkdir -p "${BUILD_TMP}" | |
build-aux/generate.sh --unparsable-packages ./unparsable-packages.yaml | |
- name: "Verify if changes were made by dependabot" | |
id: changed-by-dependabot | |
uses: datawire/go-mkopensource/actions/[email protected] | |
with: | |
branches_to_skip: master | |
push_changes: false | |
- name: "Check that action didn't do any changes" | |
run: | | |
if [[ "${{ steps.changed-by-dependabot.outputs.is_dirty }}" == 'true' ]]; then | |
echo "::error:: Action indicates that the repo was dirty" | |
exit 1 | |
fi | |
- name: "Save dependency changes made by the last committer" | |
id: changed-by-dependabot2 | |
uses: datawire/go-mkopensource/actions/[email protected] | |
with: | |
branches_to_skip: master | |
actor: ${{ github.actor }} | |
push_changes: false | |
- name: "Check that action committed changes to the repository" | |
if: github.ref_type == 'branch' && github.ref != 'refs/heads/master' | |
run: | | |
if [[ "${{ steps.changed-by-dependabot2.outputs.license_information_committed }}" != 'true' ]]; then | |
echo "::error:: Action indicates that the repo was not dirty" | |
exit 1 | |
fi | |
DESTINATION_BRANCH="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" | |
DIFF=$(git diff --stat --cached origin/${DESTINATION_BRANCH}) | |
if [[ -z "${DIFF}" ]]; then | |
echo "::error:: There weren't any files committed." | |
exit 1 | |
fi | |
if ! grep -e '^\s*DEPENDENCY_LICENSES.md' <(echo "${DIFF}") > /dev/null; then | |
echo "::error:: File DEPENDENCY_LICENSES.md was not modified, but it should have been." | |
exit 1 | |
fi |