Skip to content

Commit c25ec87

Browse files
committed
Sanitize inputs
1 parent b11ad9c commit c25ec87

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

docs-publish/action.yaml

+16-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ runs:
2929
(github.event_name == 'push' && (contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
3030
env:
3131
WEEK_CACHE: "315360" # 3600 * 24 * 7
32+
BUILD_DIR: "${{ inputs.path }}"
33+
S3_URL: "${{ inputs.url }}"
34+
CLOUDFRONT_ID: "${{ inputs.cloudfront_id }}"
3235
run: |
3336
echo "::group::Upload dev"
34-
aws s3 sync --delete "${{ inputs.path }}" "${{ inputs.url }}/en/docs/dev" --cache-control max-age=$YEAR_CACHE,public
35-
aws cloudfront create-invalidation --distribution-id "${{ inputs.cloudfront_id }}" --paths "/en/docs/dev*"
37+
aws s3 sync --delete "$BUILD_DIR" "$S3_URL/en/docs/dev" --cache-control max-age=$YEAR_CACHE,public
38+
aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_ID" --paths "/en/docs/dev*"
3639
echo "::endgroup::"
3740
- name: main
3841
shell: bash -e {0}
@@ -42,16 +45,23 @@ runs:
4245
env:
4346
WEEK_CACHE: "315360" # 3600 * 24 * 7
4447
YEAR_CACHE: "31536000" # 3600 * 24 * 365
48+
BUILD_DIR: "${{ inputs.path }}"
49+
S3_URL: "${{ inputs.url }}"
50+
CLOUDFRONT_ID: "${{ inputs.cloudfront_id }}"
51+
VERSION: "${{ inputs.version }}"
4552
run: |
4653
echo "::group::Upload main"
47-
aws s3 sync --delete "${{ inputs.path }}" "${{ inputs.url }}/en/docs/latest" --cache-control max-age=$WEEK_CACHE,public
48-
# aws s3 sync --delete "${{ inputs.path }}" "${{ inputs.url }}/en/docs/${{ inputs.version }}" --cache-control max-age=$YEAR_CACHE,public
49-
aws cloudfront create-invalidation --distribution-id "${{ inputs.cloudfront_id }}" --paths "/en/docs/latest*" "/en/docs/${{ inputs.version }}*"
54+
aws s3 sync --delete "$BUILD_DIR" "$S3_URL/en/docs/latest" --cache-control max-age=$WEEK_CACHE,public
55+
# aws s3 sync --delete "$BUILD_DIR" "$S3_URL/en/docs/$VERSION" --cache-control max-age=$YEAR_CACHE,public
56+
aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_ID" --paths "/en/docs/latest*" "/en/docs/$VERSION*"
5057
echo "::endgroup::"
5158
- name: dryrun
5259
shell: bash -e {0}
5360
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'dryrun'
61+
env:
62+
BUILD_DIR: "${{ inputs.path }}"
63+
S3_URL: "${{ inputs.url }}"
5464
run: |
5565
echo "::group::Dryrun"
56-
aws s3 sync --delete --dryrun "${{ inputs.path }}" "${{ inputs.url }}/en/docs/latest"
66+
aws s3 sync --delete --dryrun "$BUILD_DIR" "$S3_URL/en/docs/latest"
5767
echo "::endgroup::"

0 commit comments

Comments
 (0)