-
Notifications
You must be signed in to change notification settings - Fork 140
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
Running commands after publish #25
Comments
hm, good question! you may be able to put in some shell commands after the |
I'm getting this error:
Step: - name: Clean KV cache
run: wrangler kv:key delete --binding=app cache-foo |
The action doesn't do anything besides |
@signalnerve: Two Tills requesting this feature, must be a sign. |
One option for addressing would be similar to how the action was extended for secrets. Example action yaml of implementation idea: jobs:
deploy:
steps:
uses: cloudflare/wrangler-action@1.2.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
wrangler-commands: |
kv:namespace create "MY_KV"
kv:key put --binding=MY_KV "key" "value" entrypoint.sh could be updated as: # If an environment is detected as input, for each secret specified get the value of
# the matching named environment variable then configure using wrangler secret put.
if [ -z "$INPUT_ENVIRONMENT" ]
then
wrangler publish
for SECRET in $INPUT_SECRETS; do
VALUE=$(printenv "$SECRET") || secret_not_found "$SECRET"
echo "$VALUE" | wrangler secret put "$SECRET"
done
# ** New feature for handling arbitrary wrangler commands **
for COMMAND in $INPUT_WRANGLER_COMMANDS; do
wrangler "$COMMAND"
done
else
wrangler publish -e "$INPUT_ENVIRONMENT"
# ** New feature for handling arbitrary wrangler commands **
for COMMAND in $INPUT_WRANGLER_COMMANDS; do
wrangler "$COMMAND" --env "$INPUT_ENVIRONMENT"
done
fi |
@bradyjoslin, nice! Can you submit a PR? |
That's sort of pseudocode above just to express an idea, if implemented as written a few things wouldn't work right. But, if I get some time I'll try and prototype something out. |
Have a POC working with these changes. Update to action.yaml: ...
wranglerCommands:
description: "(Advanced) A new line deliminated string of wrangler commands. Target environment must be explicitly specified."
required: false With this update to entrypoint.sh. ...
# ** New feature for handling arbitrary wrangler commands **
printf '%s' "$INPUT_WRANGLERCOMMANDS" | while IFS= read -r COMMAND; do
OPTS=()
for OPT in $COMMAND; do
OPTS+=("$OPT")
done
wrangler "${OPTS[@]}"
OPTS=()
done Example deployment.yml that updates two kv entries using the action: ...
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
environment: "production"
workingDirectory: "test"
secrets: SECRET1
wranglerCommands: |
kv:key put --binding=STATIC_TEST_MY_KV key value
kv:key put --binding=STATIC_TEST_MY_KV key2 value2
env:
SECRET1: ${{ secrets.SECRET1 }} |
@bradyjoslin please open a pull-request? Other people can take it on if it goes stale and you don't have the time. |
@bradyjoslin this is awesome! I'm wondering if it makes more sense to have it not be wrangler subcommands, and just have a pre/post-publish inputs that you can use to execute commands inside of the |
@signalnerve Well, sort of. I need something basic like, a So as long as I can e.g. not do |
An idea for supporting builds without publish... A new optional action input That way if someone wanted to just |
@bradyjoslin I think that sounds great! :) |
@till - Awesome! PR #35 updated to include this additional option. Set the optional jobs:
deploy:
steps:
uses: cloudflare/wrangler-action@1.2.0
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
publish: false
preCommands: wrangler build |
Is it already possible to run wrangler commands after publishing?
I'd like to delete a couple of KV keys, either via several
wrangler kv:key delete
or viawrangler kv:bulk delete
.The text was updated successfully, but these errors were encountered: