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

Change force_push logic #377

Merged
merged 1 commit into from
Aug 7, 2024
Merged
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
40 changes: 19 additions & 21 deletions .github/workflows/crucible-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ on: # yamllint disable-line rule:truthy
required: false
type: string
description: Custom tag to push/delete
default: ''
action:
required: true
type: choice
options:
- push
- delete
description: Action to perform with the custom-tag (push or delete)
default: push
default: 'push'
force_push:
required: false
type: boolean
description: FORCE push (override if tag exists)
description: FORCE push (override tag)
default: false

jobs:
Expand All @@ -35,7 +36,6 @@ jobs:
timeout-minutes: 5
outputs:
tag: ${{ steps.gen-release-tag.outputs.tag }}
force: ${{ steps.get-force-push.outputs.force }}
steps:
- name: Generate release tag
id: gen-release-tag
Expand All @@ -48,14 +48,6 @@ jobs:
else
echo "tag=${{ inputs.custom_tag }}" >> $GITHUB_OUTPUT
fi
- name: Get force push flag
if: ${{ inputs.action == 'push' }}
id: get-force-push
run: |
if [ ${{ inputs.force_push == true }} ]; then
echo "force='-f'" >> $GITHUB_OUTPUT
else
echo "force=''" >> $GITHUB_OUTPUT

display-params:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -104,19 +96,22 @@ jobs:
token: ${{ steps.generate-token.outputs.token }}

- name: push/delete tag to/from the crucible repo
if: ${{ inputs.dry_run == false }}
if: ${{ inputs.dry_run == "false" }}
env:
TAG: ${{ needs.release-tag.outputs.tag }}
FORCE: ${{ needs.release-tag.outputs.force }}
run: |
cd $GITHUB_WORKSPACE
cd crucible
echo "Tags:"
git ls-remote --tags origin
if [ ${{ inputs.action == 'push' }} ]; then
if [ "${{ inputs.action }}" == "push" }} ]; then
git tag $TAG
git push origin $TAG $FORCE
elif [ ${{ inputs.action == 'delete' }} ]; then
if [ "${{ inputs.force_push }}" == "true" ]; then
git push origin $TAG --force
else
git push origin $TAG
fi
elif [ "${{ inputs.action }}" == "delete" ]; then
git push --delete origin $TAG
fi
echo "Tags:"
Expand Down Expand Up @@ -184,19 +179,22 @@ jobs:
fetch-tags: true
token: ${{ steps.generate-token.outputs.token }}
- name: push/delete release tag
if: ${{ inputs.dry_run == false }}
if: ${{ inputs.dry_run == "false" }}
env:
TAG: ${{ needs.release-tag.outputs.tag }}
FORCE: ${{ needs.release-tag.outputs.force }}
run: |
cd $GITHUB_WORKSPACE
cd ${{ matrix.repository }}
echo "Tags:"
git ls-remote --tags origin
if [ ${{ inputs.action == 'push' }} ]; then
if [ "${{ inputs.action }}" == "push" ]; then
git tag $TAG
git push origin $TAG $FORCE
elif [ ${{ inputs.action == 'delete' }} ]; then
if [ "${{ inputs.force_push }}" == "true" ]; then
git push origin $TAG --force
else
git push origin $TAG
fi
elif [ "${{ inputs.action }}" == "delete" ]; then
git push --delete origin $TAG
fi
echo "Tags:"
Expand Down