Merge pull request #507 from redhatci/certsuite-v5.4.0 #399
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: Ansible Galaxy Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Add epoch from commit date as patch version in galaxy.yml | |
run: | | |
set -x | |
z=$(TZ=UTC0 git show ${{ github.sha }} --no-patch --format=%cd --date=format-local:'%s') | |
ts=$(TZ=UTC0 git show ${{ github.sha }} --no-patch --format=%cd --date=format-local:'%Y%m%d%H%M') | |
sha=$(echo "${{ github.sha }}" | cut -c1-7) | |
cat >> galaxy.yml <<EOF | |
- "ts$ts" | |
- "git$sha" | |
EOF | |
tail -10 galaxy.yml | |
sed -i -r "s/^(version: .*)\.0$/\1.${z}/" galaxy.yml | |
grep ^version galaxy.yml | |
# Build and publish manually due to https://github.com/ansible/galaxy/issues/3287 | |
# ansible/ansible-publish-action implements this | |
# https://github.com/ansible/creator-ee/blob/main/_build/devtools-publish | |
- name: Ansible Galaxy Collection Publish | |
run: > | |
rm -f ./*.tar.gz; | |
ansible-galaxy collection build -v --force "${SRC_PATH:-.}"; | |
TARBALL=$(ls -1 ./*.tar.gz); | |
set +e; | |
publish=$(ansible-galaxy collection publish -v \ | |
--server "${API_SERVER:-https://galaxy.ansible.com/}" \ | |
--api-key "${{ secrets.ANSIBLE_GALAXY_TOKEN }}" \ | |
"${TARBALL}" 2>&1 | |
); | |
if [[ $? -ne 0 ]]; then | |
set -e; | |
err="Error when publishing collection to cmd_arg .*HTTP Code: 500, Message:"; | |
err500="Internal Server Error Code: Unknown"; | |
if grep -qP "${err} ${err500}" <<< "${publish}"; then | |
echo "Error found https://github.com/ansible/galaxy/issues/3287, Ignoring..."; | |
echo "${publish}"; | |
ec=0; | |
else | |
echo "${publish}"; | |
ec=1; | |
fi; | |
exit ${ec} | |
fi; | |
- name: Notify failure | |
if: ${{ failure() }} | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
ENABLE_ESCAPES: true | |
MSG_MINIMAL: true | |
SLACK_COLOR: ${{ job.status }} | |
SLACK_FOOTER: "version: ${{ steps.galaxy.outputs.ver }}" | |
SLACKIFY_MARKDOWN: true | |
SLACK_MESSAGE: > | |
URL: [${{ github.workflow }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}/checks) | |
SLACK_TITLE: 🔴 Galaxy Publication Failure | |
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} |