Skip to content

Commit

Permalink
Merge branch 'master' into jlandells-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzei authored Nov 7, 2024
2 parents d26b14d + aed9e31 commit 4d49984
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 177 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 }}
48 changes: 27 additions & 21 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
module mattermost-developer-documentation

go 1.19
go 1.22

toolchain go1.22.7

require (
github.com/mattermost/mattermost/server/public v0.0.14
github.com/mattermost/mattermost/server/public v0.1.7
github.com/pkg/errors v0.9.1
golang.org/x/tools v0.16.1
golang.org/x/tools v0.23.0
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/dyatlov/go-opengraph/opengraph v0.0.0-20220524092352-606d7b1e5f8a // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.5 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/go-hclog v1.6.2 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/go-asn1-ber/asn1-ber v1.5.7 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404 // indirect
Expand All @@ -31,20 +36,21 @@ require (
github.com/oklog/run v1.1.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/tinylib/msgp v1.1.9 // indirect
github.com/philhofer/fwd v1.1.3-0.20240612014219-fbbf4953d986 // indirect
github.com/tinylib/msgp v1.2.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/wiggin77/merror v1.0.5 // indirect
github.com/wiggin77/srslog v1.0.1 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/grpc v1.60.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 4d49984

Please sign in to comment.