-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jlandells-patch-1
- Loading branch information
Showing
13 changed files
with
236 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,74 @@ | ||
name: preview-env-fork-setup-update | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["check-label-preview-env"] | ||
types: [completed] | ||
workflow_dispatch: | ||
inputs: | ||
PR_NUMBER: | ||
type: string | ||
required: true | ||
TRIGGERING_ACTOR: | ||
type: string | ||
required: true | ||
COMMIT_SHA: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
update-initial-status: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Download PR number artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: ${{ github.event.workflow_run.workflow_id }} | ||
name: pr.txt | ||
- name: Save PR number | ||
id: pr | ||
run: | | ||
echo "::set-output name=id::$(<pr.txt)" | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_sha }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@v2 | ||
with: | ||
hugo-version: 0.101.0 | ||
extended: true | ||
|
||
- name: Build Previews | ||
run: | | ||
rm -rf ./dist | ||
make plugin-data | ||
hugo -F -s site --baseURL http://mattermost-dev-docs-preview-pulls.s3-website-us-east-1.amazonaws.com/${{ steps.pr.outputs.id }}/ --destination ../dist/html | ||
- name: package/update-initial-status | ||
uses: mattermost/actions/delivery/update-commit-status@fec7b836001c9380d4bfaf28d443945c103a098c | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
repository_full_name: ${{ github.repository }} | ||
commit_sha: ${{ inputs.COMMIT_SHA }} | ||
context: "preview-env-fork-setup-update / deploy" | ||
description: "Pipeline for docs generation for ${{ inputs.COMMIT_SHA }} is running" | ||
status: pending | ||
|
||
- uses: shallwefootball/s3-upload-action@master | ||
name: Upload Preview Env | ||
with: | ||
aws_key_id: ${{ secrets.AWS_KEY_ID }} | ||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws_bucket: ${{ secrets.AWS_BUCKET }} | ||
source_dir: ./dist/html | ||
destination_dir: ${{ steps.pr.outputs.id }} | ||
deploy: | ||
uses: ./.github/workflows/preview-env-template.yml | ||
secrets: inherit | ||
needs: | ||
- update-initial-status | ||
with: | ||
PR_NUMBER: ${{ inputs.PR_NUMBER }} | ||
TRIGGERING_ACTOR: ${{ inputs.TRIGGERING_ACTOR }} | ||
COMMIT_SHA: ${{ inputs.COMMIT_SHA }} | ||
|
||
- name: Add comment to PR | ||
uses: peter-evans/create-or-update-comment@v1 | ||
if: ${{ success() }} | ||
# We need to duplicate here in order to set the proper commit status | ||
# https://mattermost.atlassian.net/browse/CLD-5815 | ||
update-failure-final-status: | ||
runs-on: ubuntu-latest | ||
if: failure() || cancelled() | ||
needs: | ||
- deploy | ||
steps: | ||
- uses: mattermost/actions/delivery/update-commit-status@fec7b836001c9380d4bfaf28d443945c103a098c | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ steps.pr.outputs.id }} | ||
body: | | ||
Newest code from ${{ github.actor }} has been published to [preview environment](http://mattermost-dev-docs-preview-pulls.s3-website-us-east-1.amazonaws.com/${{ steps.pr.outputs.id }}) for Git SHA ${{ github.event.workflow_run.head_sha }} | ||
repository_full_name: ${{ github.repository }} | ||
commit_sha: ${{ inputs.COMMIT_SHA }} | ||
context: "preview-env-fork-setup-update / deploy" | ||
description: "Pipeline for docs generation for ${{ inputs.COMMIT_SHA }} failed~" | ||
status: failure | ||
|
||
- name: The job has failed | ||
if: ${{ failure() }} | ||
uses: peter-evans/create-or-update-comment@v1 | ||
# https://mattermost.atlassian.net/browse/CLD-5815 | ||
update-success-final-status: | ||
runs-on: ubuntu-latest | ||
if: success() | ||
needs: | ||
- deploy | ||
steps: | ||
- uses: mattermost/actions/delivery/update-commit-status@fec7b836001c9380d4bfaf28d443945c103a098c | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ steps.pr.outputs.id }} | ||
body: Preview environment failed. | ||
repository_full_name: ${{ github.repository }} | ||
commit_sha: ${{ inputs.COMMIT_SHA }} | ||
context: "preview-env-fork-setup-update / deploy" | ||
description: "Pipeline for docs generation for ${{ inputs.COMMIT_SHA }} succeeded" | ||
status: success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: preview-env-template | ||
|
||
# on: | ||
# pull_request: | ||
# types: [assigned, opened, reopened, synchronize] | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
PR_NUMBER: | ||
type: string | ||
required: true | ||
TRIGGERING_ACTOR: | ||
type: string | ||
required: true | ||
COMMIT_SHA: | ||
type: string | ||
required: true | ||
|
||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
ref: ${{ inputs.COMMIT_SHA }} | ||
|
||
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | ||
with: | ||
go-version-file: go.mod | ||
|
||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 | ||
with: | ||
hugo-version: 0.101.0 | ||
extended: true | ||
|
||
- name: Build Previews | ||
run: | | ||
rm -rf ./dist | ||
make plugin-data | ||
hugo -F -s site --baseURL http://mattermost-dev-docs-preview-pulls.s3-website-us-east-1.amazonaws.com/${{ inputs.PR_NUMBER }}/ --destination ../dist/html | ||
- name: Run tests | ||
run: make test | ||
|
||
- uses: shallwefootball/s3-upload-action@4350529f410221787ccf424e50133cbc1b52704e # v1.3.3 | ||
name: Upload Preview Env | ||
with: | ||
aws_key_id: ${{ secrets.AWS_KEY_ID }} | ||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws_bucket: mattermost-dev-docs-preview-pulls | ||
source_dir: ./dist/html | ||
destination_dir: ${{ inputs.PR_NUMBER }} | ||
|
||
|
||
- name: Add comment to PR | ||
uses: peter-evans/create-or-update-comment@7dfe4b0aa0c4bbd06d172692ff8a9e18381d6979 # v3.0.1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
issue-number: ${{ inputs.PR_NUMBER }} | ||
body: | | ||
Newest code from ${{ inputs.TRIGGERING_ACTOR }} has been published to [preview environment](http://mattermost-dev-docs-preview-pulls.s3-website-us-east-1.amazonaws.com/${{ inputs.PR_NUMBER }}) for Git SHA ${{ inputs.COMMIT_SHA }} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.