From 6a9c79f8d08b52d0d150620a9985b32c6c85e667 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 17:24:45 -0400 Subject: [PATCH 01/11] feat: add initial files needed to deploy this as a site for testing purposes --- .static | 1 + site/index.html | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .static create mode 100644 site/index.html diff --git a/.static b/.static new file mode 100644 index 0000000..df0d2bf --- /dev/null +++ b/.static @@ -0,0 +1 @@ +.static \ No newline at end of file diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..ecce221 --- /dev/null +++ b/site/index.html @@ -0,0 +1,45 @@ + + + + Example Domain + + + + + + + + +
+

Example Domain

+

This domain is for use in illustrative examples in documents. You may use this + domain in literature without prior coordination or asking for permission.

+

More information...

+
+ + From 1769636cc88cf8debb8a195e2ab36eef39167f30 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 17:31:47 -0400 Subject: [PATCH 02/11] tests: test deploys via github action --- .github/workflows/deploy.yml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..a412c28 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,43 @@ +--- +name: 'deploy' + +# yamllint disable-line rule:truthy +on: + # onl run this workflow on pull request events + pull_request + +jobs: + review_app: + runs-on: ubuntu-latest + # only run when a pull request is opened + if: github.event_name == 'pull_request' && github.event.action == 'opened' + steps: + - name: Cloning repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Push to dokku + uses: dokku/github-action@master + with: + # create a review app + command: review-apps:create + git_remote_url: 'ssh://dokku@dokku.com/nginx-buildpack' + # specify a name for the review app + review_app_name: nginx-buildpack-${{ github.event.pull_request.number }} + ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} + + destroy_review_app: + runs-on: ubuntu-latest + # only run when a pull request is closed + if: github.event_name == 'pull_request' && github.event.action == 'closed' + steps: + - name: Destroy the review app + uses: dokku/github-action@master + with: + # destroy a review app + command: review-apps:destroy + git_remote_url: 'ssh://dokku@dokku.me:22/nginx-buildpack' + # specify a name for the review app + review_app_name: nginx-buildpack-${{ github.event.pull_request.number }} + ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} From 648d73fda6f6a02c22c5ad3a56f6aac520e75a95 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 17:38:10 -0400 Subject: [PATCH 03/11] fix: set current buildpack as the buildpack to use --- .github/workflows/deploy.yml | 2 ++ bin/ci-pre-deploy | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 bin/ci-pre-deploy diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a412c28..953cc78 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,6 +23,8 @@ jobs: # create a review app command: review-apps:create git_remote_url: 'ssh://dokku@dokku.com/nginx-buildpack' + # specify `--force` as a flag for git pushes + git_push_flags: '--force' # specify a name for the review app review_app_name: nginx-buildpack-${{ github.event.pull_request.number }} ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy new file mode 100644 index 0000000..52f35ee --- /dev/null +++ b/bin/ci-pre-deploy @@ -0,0 +1,8 @@ +#!/bin/sh -l +if [ "$IS_REVIEW_APP" = "true" ]; then + echo "https://github.com/${GITHUB_REPOSITORY}.git#$GITHUB_SHA" > .buildpacks + git add .buildpacks + git config --global user.name 'Dokku Bot' + git config --global user.email no-reply@dokku.com + git commit -m "feat: specify $GITHUB_SHA as buildpack" +fi \ No newline at end of file From 6a73313edb6696ed38ad3d9bcd6cc33636c370b3 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 17:41:00 -0400 Subject: [PATCH 04/11] fix: always run the first job --- .github/workflows/deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 953cc78..fa762f7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,8 +9,6 @@ on: jobs: review_app: runs-on: ubuntu-latest - # only run when a pull request is opened - if: github.event_name == 'pull_request' && github.event.action == 'opened' steps: - name: Cloning repo uses: actions/checkout@v2 From e28d2049e5a2673175729ebbeb95ebc03c615bd1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 17:42:55 -0400 Subject: [PATCH 05/11] debug: see what directory we are in --- bin/ci-pre-deploy | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy index 52f35ee..c083098 100644 --- a/bin/ci-pre-deploy +++ b/bin/ci-pre-deploy @@ -1,4 +1,5 @@ #!/bin/sh -l +ls -lah if [ "$IS_REVIEW_APP" = "true" ]; then echo "https://github.com/${GITHUB_REPOSITORY}.git#$GITHUB_SHA" > .buildpacks git add .buildpacks From 1a28ec850949a57e48c740857195e8e51a19ad80 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 17:53:28 -0400 Subject: [PATCH 06/11] feat: purge cache on every review app deploy This ensures we test the currently built nginx binary. --- bin/ci-pre-deploy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy index c083098..9630f00 100644 --- a/bin/ci-pre-deploy +++ b/bin/ci-pre-deploy @@ -1,6 +1,9 @@ #!/bin/sh -l ls -lah if [ "$IS_REVIEW_APP" = "true" ]; then + echo "purging repo cache" + ssh "$SSH_REMOTE" -- repo:purge-cache "$APP_NAME" + echo "https://github.com/${GITHUB_REPOSITORY}.git#$GITHUB_SHA" > .buildpacks git add .buildpacks git config --global user.name 'Dokku Bot' From 22619107ab8c3a907a6c313aaf1b2138e7fea10d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 17:58:38 -0400 Subject: [PATCH 07/11] chore: silence ci hook --- bin/ci-pre-deploy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy index 9630f00..20136e1 100644 --- a/bin/ci-pre-deploy +++ b/bin/ci-pre-deploy @@ -1,5 +1,4 @@ #!/bin/sh -l -ls -lah if [ "$IS_REVIEW_APP" = "true" ]; then echo "purging repo cache" ssh "$SSH_REMOTE" -- repo:purge-cache "$APP_NAME" @@ -8,5 +7,5 @@ if [ "$IS_REVIEW_APP" = "true" ]; then git add .buildpacks git config --global user.name 'Dokku Bot' git config --global user.email no-reply@dokku.com - git commit -m "feat: specify $GITHUB_SHA as buildpack" + git commit -qm "feat: specify $GITHUB_SHA as buildpack" fi \ No newline at end of file From 7794c2c36f0be7b1e1f34b449d23a269532f838e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 18:02:11 -0400 Subject: [PATCH 08/11] chore: add some debugging information --- bin/ci-pre-deploy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy index 20136e1..afb955b 100644 --- a/bin/ci-pre-deploy +++ b/bin/ci-pre-deploy @@ -1,8 +1,9 @@ #!/bin/sh -l if [ "$IS_REVIEW_APP" = "true" ]; then - echo "purging repo cache" + echo "-----> Purging repo cache" ssh "$SSH_REMOTE" -- repo:purge-cache "$APP_NAME" + echo "-----> Setting the buildpack to the current commit" echo "https://github.com/${GITHUB_REPOSITORY}.git#$GITHUB_SHA" > .buildpacks git add .buildpacks git config --global user.name 'Dokku Bot' From f981b138ed9713a4d926ca8870fafd960b3416e5 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 18:04:40 -0400 Subject: [PATCH 09/11] fix: use a dokku.net subdomain to avoid hsts issues --- bin/ci-pre-deploy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy index afb955b..fbd89b2 100644 --- a/bin/ci-pre-deploy +++ b/bin/ci-pre-deploy @@ -3,6 +3,9 @@ if [ "$IS_REVIEW_APP" = "true" ]; then echo "-----> Purging repo cache" ssh "$SSH_REMOTE" -- repo:purge-cache "$APP_NAME" + echo "-----> Setting the test domain name" + ssh "$SSH_REMOTE" -- repo:purge-cache "$APP_NAME" "$APP_NAME.dokku.net" + echo "-----> Setting the buildpack to the current commit" echo "https://github.com/${GITHUB_REPOSITORY}.git#$GITHUB_SHA" > .buildpacks git add .buildpacks From faf2a7027261393defa1bc3a9bd2568fccc46f28 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 18:09:06 -0400 Subject: [PATCH 10/11] fix: use correct domain name --- bin/ci-pre-deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ci-pre-deploy b/bin/ci-pre-deploy index fbd89b2..08b7600 100644 --- a/bin/ci-pre-deploy +++ b/bin/ci-pre-deploy @@ -4,7 +4,7 @@ if [ "$IS_REVIEW_APP" = "true" ]; then ssh "$SSH_REMOTE" -- repo:purge-cache "$APP_NAME" echo "-----> Setting the test domain name" - ssh "$SSH_REMOTE" -- repo:purge-cache "$APP_NAME" "$APP_NAME.dokku.net" + ssh "$SSH_REMOTE" -- domains:set "$APP_NAME" "$APP_NAME.dokku.net" echo "-----> Setting the buildpack to the current commit" echo "https://github.com/${GITHUB_REPOSITORY}.git#$GITHUB_SHA" > .buildpacks From 0e7bef86f93977aa5555596c14b925532625c3d3 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 10 Sep 2022 18:09:55 -0400 Subject: [PATCH 11/11] chore: ensure robots do not crawl these test domains --- site/robots.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 site/robots.txt diff --git a/site/robots.txt b/site/robots.txt new file mode 100644 index 0000000..77470cb --- /dev/null +++ b/site/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file