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

Environment names with spaces no longer work #298

Closed
hashtagchris opened this issue Aug 30, 2024 · 5 comments
Closed

Environment names with spaces no longer work #298

hashtagchris opened this issue Aug 30, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@hashtagchris
Copy link
Member

Describe the Issue

npm upgraded directly from v4.4.0 to 9.4.0. It mostly went smoothly, but our database migration workflows stopped working. Our environment names include up and down to support reverting migrations.

Action Configuration

    steps:
      - name: branch-deploy
        id: branch-deploy
        uses: github/branch-deploy@91f77d0f24b03ff5f3d0fd24ce45498d1690d16b # pin 9.4.0
        with:
          environment: up sandbox
          environment_targets: up sandbox,down sandbox,up staging,down staging,up production,down production
          stable_branch: ${{ inputs.main_branch }}
          trigger: ".migrate"
          # We don't want the migration locks to interfere with the main chatops workflow
          lock_trigger: .an-lock-random-obscure-string-that-shouldnt-be-typed-ever
          unlock_trigger: .an-unlock-random-obscure-string-that-shouldnt-be-typed-ever
          skip_reviews: 'up sandbox,down sandbox'
          update_branch: warn

Relevant Actions Log Output

2024-08-22T19:44:55.6510210Z ##[group]Run github/branch-deploy@91f77d0f24b03ff5f3d0fd24ce45498d1690d16b
2024-08-22T19:44:55.6511127Z with:
2024-08-22T19:44:55.6511561Z   environment: up sandbox
2024-08-22T19:44:55.6512588Z   environment_targets: up sandbox,down sandbox,up staging,down staging,up production,down production
2024-08-22T19:44:55.6513632Z   stable_branch: master
2024-08-22T19:44:55.6514139Z   trigger: .migrate
2024-08-22T19:44:55.6514882Z   lock_trigger: .an-lock-random-obscure-string-that-shouldnt-be-typed-ever
2024-08-22T19:44:55.6516123Z   unlock_trigger: .an-unlock-random-obscure-string-that-shouldnt-be-typed-ever
2024-08-22T19:44:55.6517272Z   skip_reviews: up sandbox,down sandbox
2024-08-22T19:44:55.6518004Z   update_branch: warn
2024-08-22T19:44:55.6518711Z   github_token: ***
2024-08-22T19:44:55.6519184Z   status: success
2024-08-22T19:44:55.6519595Z   environment_url_in_comment: true
2024-08-22T19:44:55.6520209Z   production_environments: production
2024-08-22T19:44:55.6520898Z   reaction: eyes
2024-08-22T19:44:55.6521327Z   noop_trigger: .noop
2024-08-22T19:44:55.6521769Z   help_trigger: .help
2024-08-22T19:44:55.6522247Z   lock_info_alias: .wcid
2024-08-22T19:44:55.6522747Z   permissions: write,maintain,admin
2024-08-22T19:44:55.6523329Z   param_separator: |
2024-08-22T19:44:55.6523914Z   global_lock_flag: --global
2024-08-22T19:44:55.6524415Z   outdated_mode: strict
2024-08-22T19:44:55.6525146Z   required_contexts: false
2024-08-22T19:44:55.6525632Z   checks: all
2024-08-22T19:44:55.6526016Z   allow_forks: true
2024-08-22T19:44:55.6526449Z   admins: false
2024-08-22T19:44:55.6526822Z   admins_pat: false
2024-08-22T19:44:55.6527240Z   merge_deploy_mode: false
2024-08-22T19:44:55.6527750Z   unlock_on_merge_mode: false
2024-08-22T19:44:55.6528241Z   skip_completing: false
2024-08-22T19:44:55.6528824Z   deploy_message_path: .github/deployment_message.md
2024-08-22T19:44:55.6529453Z   sticky_locks: false
2024-08-22T19:44:55.6529890Z   sticky_locks_for_noop: false
2024-08-22T19:44:55.6530427Z   allow_sha_deployments: false
2024-08-22T19:44:55.6530965Z   disable_naked_commands: false
2024-08-22T19:44:55.6531545Z   skip_successful_noop_labels_if_approved: false
2024-08-22T19:44:55.6532244Z   skip_successful_deploy_labels_if_approved: false
2024-08-22T19:44:55.6532892Z ##[endgroup]
2024-08-22T19:44:55.9986797Z ✅ comment body starts with trigger: �[35m.migrate
2024-08-22T19:44:56.3924857Z 🌍 environment: �[35mup sandbox
2024-08-22T19:44:57.9089891Z ✅ CI checks passed and required reviewers have been disabled for this environment
2024-08-22T19:44:57.9102769Z 🍯 sticky_locks: �[35mfalse�[0m
2024-08-22T19:44:57.9107906Z 🍯 sticky_locks_for_noop: �[35mfalse�[0m
2024-08-22T19:44:58.6947265Z ##[error]HttpError: refs/heads/up sandbox-branch-deploy-lock is not a valid ref name. - https://docs.github.com/rest/git/refs#create-a-reference
    at /home/runner/work/_actions/github/branch-deploy/91f77d0f24b03ff5f3d0fd24ce45498d1690d16b/node_modules/@octokit/request/dist-node/index.js:125:1
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at createBranch (/home/runner/work/_actions/github/branch-deploy/91f77d0f24b03ff5f3d0fd24ce45498d1690d16b/src/functions/lock.js:290:1)
    at lock (/home/runner/work/_actions/github/branch-deploy/91f77d0f24b03ff5f3d0fd24ce45498d1690d16b/src/functions/lock.js:642:1)
    at run (/home/runner/work/_actions/github/branch-deploy/91f77d0f24b03ff5f3d0fd24ce45498d1690d16b/src/main.js:517:1)
2024-08-22T19:44:58.6966927Z ##[error]refs/heads/up sandbox-branch-deploy-lock is not a valid ref name. - https://docs.github.com/rest/git/refs#create-a-reference
2024-08-22T19:44:58.7364488Z Post job cleanup.
2024-08-22T19:44:58.8300657Z ##[warning]⛔ �[35mbypass�[0m set, exiting
2024-08-22T19:44:58.8507136Z Cleaning up orphan processes

Extra Information

No response

@hashtagchris hashtagchris added the bug Something isn't working label Aug 30, 2024
@GrantBirki
Copy link
Member

refs/heads/up sandbox-branch-deploy-lock is not a valid ref name

This certainly looks like its related to the upgrade that changed the way this Action handles locks. In the latest version of this Action, locks are environment specific. So it looks like a lock is trying to be created for the up sandbox environment. However this fails the GitHub API validation for new branches as up sandbox-branch-deploy-lock is an invalid ref name as it contains a space. I'll need to do some digging to look into a non-breaking way to fix this.

@GrantBirki
Copy link
Member

...Thinking out loud

I think it would be a good idea to simply translate the environment names to valid branch names for locking functionality.

Example:

up sandbox becomes up-sandbox-branch-deploy-lock.

This should be the only change required.

@GrantBirki
Copy link
Member

@hashtagchris I have published a pre-release (v9.7.0) that should fix this problem. When you have a moment to try it out, let me know if it fixes your issue. Thank you! 🙇

@GrantBirki
Copy link
Member

Related pre-release for users of the github/lock action: https://github.com/github/lock/releases/tag/v2.3.0

@hashtagchris
Copy link
Member Author

@GrantBirki Looks like it works. Thank you!

issue comment

.migrate up sandbox

Actions logging

Run github/branch-deploy@4445cd011b320a788114409e6c6f855732b20a3e
✅ comment body starts with trigger: .migrate
🌍 environment: up sandbox
✅ CI checks passed and required reviewers have been disabled for this environment
🍯 sticky_locks: false
🍯 sticky_locks_for_noop: false
🔒 created lock branch: up-sandbox-branch-deploy-lock
✅ deployment lock obtained
🚀 deployment started!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants