Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
toninis authored Oct 4, 2024
2 parents b5b3bd0 + d764df8 commit 3435f06
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 96 deletions.
118 changes: 62 additions & 56 deletions .github/workflows/preview-env-fork.yml
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
67 changes: 67 additions & 0 deletions .github/workflows/preview-env-template.yml
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 }}
44 changes: 6 additions & 38 deletions .github/workflows/preview-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,10 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
uses: ./.github/workflows/preview-env-template.yml
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v2
with:
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/${{ github.event.number }}/ --destination ../dist/html
- name: Run tests
run: make test

- 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: ${{ github.event.number }}

- name: Add comment to PR
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.number }}
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/${{ github.event.number }}) for Git SHA ${{ github.event.pull_request.head.sha }}
secrets: inherit
with:
PR_NUMBER: ${{ github.event.number }}
TRIGGERING_ACTOR: ${{ github.event.pull_request.head.user.login }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
4 changes: 2 additions & 2 deletions site/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ enableEmoji = true

[params.notification]
enable = true
url = "https://mattermost.com/blog/microsoft-teams-m365-mission-critical-workflows/"
text = "Mattermost v10.0 is now available! Learn what’s new »"
url = "https://mattermost.com/hacktoberfest/"
text = "Hacktoberfest is here! Contribute, collaborate & earn rewards."

[params.search]
enable = true
Expand Down

0 comments on commit 3435f06

Please sign in to comment.