Skip to content

Commit

Permalink
Refactor to clone the repositories
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
  • Loading branch information
jdbaldry committed Jan 30, 2025
1 parent 8f5508f commit 7507df0
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 277 deletions.
40 changes: 15 additions & 25 deletions .github/workflows/deploy-pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,18 @@ concurrency:

jobs:
deploy-pr-preview:
if: ${{ ! github.event.pull_request.head.repo.fork }}
permissions:
contents: read
id-token: write # Fetch Vault secrets.
pull-requests: write # Create or update PR comments.
statuses: write # Update GitHub status check with deploy preview link.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- uses: ./deploy-preview
with:
branch: ${{ github.head_ref }}
event_number: ${{ github.event.number }}
sha: ${{ github.event.pull_request.head.sha }}
sources: |
[{
"index_file": null,
"relative_prefix": "/docs/writers-toolkit/",
"source_directory": "docs/sources",
"website_directory": "content/docs/writers-toolkit"
}]
title: ${{ github.event.pull_request.title }}
if: "!github.event.pull_request.head.repo.fork"
uses: grafana/writers-toolkit/.github/workflows/deploy-preview.yml@main
with:
branch: ${{ github.head_ref }}
event_number: ${{ github.event.number }}
sha: ${{ github.event.pull_request.head.sha }}
sources: |
[{
"index_file": null,
"relative_prefix": "/docs/writers-toolkit/",
"repo": writers-toolkit",
"source_directory": "docs/sources",
"website_directory": "content/docs/writers-toolkit"
}]
title: ${{ github.event.pull_request.title }}
18 changes: 7 additions & 11 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,17 @@ on:
env:
CLOUD_RUN_REGION: us-south1

permissions:
id-token: write # Needed for authentication.
statuses: write # Needed to send deploy preview link as a commit status.
pull-requests: write # Needed to add/update a comment with the deploy preview link.

concurrency:
group: ${{ github.workflow }}-${{ inputs.repo }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
deploy-preview:
permissions: write-all
permissions:
contents: read # Clone repositories.
id-token: write # Fetch Vault secrets.
pull-requests: write # Create or update PR comments.
statuses: write # Update GitHub status check with deploy preview link.
runs-on: ubuntu-latest
steps:
- name: Find comment
Expand Down Expand Up @@ -117,7 +116,7 @@ jobs:
shell: bash
run: |
shopt -s extglob
rm -rf !(docs|deploy-preview-files|.git)
rm -rf !(deploy-preview-files|.git)
ls -al
ls -al ${{ inputs.source_directory }}
ls -al deploy-preview-files
Expand All @@ -126,10 +125,7 @@ jobs:
if: github.event.action == 'opened' || github.event.action == 'synchronize'
shell: bash
env:
SOURCE_DIRECTORY: ${{ inputs.source_directory }}
WEBSITE_DIRECTORY: ${{ inputs.website_directory }}
INDEX_FILE: ${{ inputs.index_file }}
REPO: ${{ inputs.repo }}
SOURCES: ${{ inputs.SOURCES }}
run: |
./deploy-preview-files/deploy-preview/build.sh
Expand Down
10 changes: 4 additions & 6 deletions deploy-preview/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
FROM nginx:1.21.6-alpine
ARG ACTION_PATH
ENV ACTION_PATH="${ACTION_PATH:-deploy-preview-files/deploy-preview/}"

COPY ./dist /usr/share/nginx/dist

RUN rm -rf /etc/nginx/sites-enabled && \
rm -rf /etc/nginx/nginx.conf

COPY "${ACTION_PATH}/deploy-preview-files/deploy-preview/nginx.conf" /etc/nginx/nginx.conf
COPY deploy-preview-files/deploy-preview/nginx.conf /etc/nginx/nginx.conf
COPY build.conf /etc/nginx/build.conf

COPY ./dist /usr/share/nginx/dist

RUN nginx -t
RUN nginx -t
218 changes: 0 additions & 218 deletions deploy-preview/action.yml

This file was deleted.

Loading

0 comments on commit 7507df0

Please sign in to comment.