Skip to content

Commit 065f263

Browse files
committed
update to also publish to main
1 parent 23e41c7 commit 065f263

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

docs-publish/action.yaml

+9-8
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,31 @@ inputs:
88
description: The cloudfront id
99
required: true
1010
version:
11-
description: The full version of the package
11+
description: The version (only if target is main)
1212
required: true
1313
path:
1414
description: The folder to upload
1515
default: ./builtdocs/
1616

1717
runs:
1818
using: "composite"
19+
env:
20+
WEEK_CACHE: "315360" # 3600 * 24 * 7
21+
YEAR_CACHE: "31536000" # 3600 * 24 * 365
1922
steps:
2023
- shell: bash -e {0}
2124
id: vars
2225
run: |
23-
echo "Deploying from ref ${GITHUB_REF#refs/*/}"
26+
echo "Deploying from ref: ${GITHUB_REF#refs/*/}"
2427
echo "tag=${GITHUB_REF#refs/*/}" > $GITHUB_OUTPUT
25-
echo "version=${{ inputs.version }}"
2628
- name: dev
2729
shell: bash -e {0}
2830
if: |
2931
(github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'dev') ||
3032
(github.event_name == 'push' && (contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
3133
run: |
3234
echo "::group::Upload dev"
33-
aws s3 sync --delete "${{ inputs.path }}" "${{ inputs.url }}/en/docs/dev"
35+
aws s3 sync --delete "${{ inputs.path }}" "${{ inputs.url }}/en/docs/dev" --cache-control max-age=$YEAR_CACHE,public
3436
aws cloudfront create-invalidation --distribution-id "${{ inputs.cloudfront_id }}" --paths "/en/docs/dev*"
3537
echo "::endgroup::"
3638
- name: main
@@ -40,10 +42,9 @@ runs:
4042
(github.event_name == 'push' && !(contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
4143
run: |
4244
echo "::group::Upload main"
43-
echo "MAIN"
44-
# aws s3 sync --delete --dryrun "${{ inputs.path }}" "${{ inputs.url }}/en/docs/latest"
45-
# TODO: Version should work with workflow dispatch
46-
# aws s3 sync --delete --dryrun "${{ inputs.path }}" "${{ inputs.url }}/en/docs/${{ inputs.version }}"
45+
aws s3 sync --delete --dryrun "${{ inputs.path }}" "${{ inputs.url }}/en/docs/latest" --cache-control max-age=$WEEK_CACHE,public
46+
aws s3 sync --delete --dryrun "${{ inputs.path }}" "${{ inputs.url }}/en/docs/${{ inputs.version }}" --cache-control max-age=$YEAR_CACHE,public
47+
aws cloudfront create-invalidation --distribution-id "${{ inputs.cloudfront_id }}" --paths "/en/docs/latest*" "/en/docs/${{ inputs.version }}"
4748
echo "::endgroup::"
4849
- name: dryrun
4950
shell: bash -e {0}

0 commit comments

Comments
 (0)