You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently both publishing workflows: publish-dev.yml and publish-master.yml use duplicated code which verifies if tag version is the same as checked out python package version (stored in src/getfx/__init__.py.
Ideally this duplicated code should be replaced with a new GitHub Action:
preferably should be written in Node.js (preferred over docker as it takes at least 15-30s to build an image)
(nice to have) such action should use repository (or environment) secret to run or not (by default run)
Example of code snippet to be converted to GitHub Action:
- name: Set variablesid: get_versionrun: | echo ::set-output name=TAG_VER::$(echo $GITHUB_REF | cut -d / -f 3) echo "GETFX_SRC_VER=v$(cat src/getfx/__init__.py | grep version | awk -F"= " '{ print $2 }' | sed 's/"//g')" >> $GITHUB_ENV echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-8)" >> $GITHUB_ENV
- name: Fail if SRC and GIT TAG versions are differentif: env.GETFX_SRC_VER != steps.get_version.outputs.TAG_VERuses: actions/github-script@v3with:
script: core.setFailed('Different tag and SRC versions ${{ steps.get_version.outputs.TAG_VER}} vs ${{ env.GETFX_SRC_VER}}')
Note:
first and second echo commands are specific to the new GitHub action and can be replaced by it
third echo command is required only by later parts of workflow action which uses it for publishing documentation (it should remain in workflow action)
kniklas
changed the title
Write GitHub Action for package/tag version verification
Write GitHub Action for package/tag version verification (avoid duplication of code in GitHub Actions)
Oct 27, 2021
Currently both publishing workflows:
publish-dev.yml
andpublish-master.yml
use duplicated code which verifies if tag version is the same as checked out python package version (stored insrc/getfx/__init__.py
.Ideally this duplicated code should be replaced with a new GitHub Action:
Example of code snippet to be converted to GitHub Action:
Note:
Note on using secrets in
if:
statementsThere was an attempt to add in if: statement secret that would indicate if this check should be performed, but after few trials it was not successful. Probably this can be overcome (https://stackoverflow.com/questions/61255989/dynamically-retrieve-github-actions-secret) but apparently secrets can't be used for that purpose: actions/runner#520
Additionally following link could be check if will be useful: https://github.com/marketplace/actions/secret-input-gate
Not sure if this problem will manifest for new GitHub Action.
The text was updated successfully, but these errors were encountered: