-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 4225-emphasise-that-the-composable-image-is-…
…a-beta-version-on-create-apps-page-comprehensive-example
- Loading branch information
Showing
750 changed files
with
490,528 additions
and
184 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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Get PR URL | ||
description: Checks the status of the environment based on branch, returns environment URL | ||
inputs: | ||
platformsh_token: | ||
description: 'Platform.sh/Upsun.com API token' | ||
required: true | ||
branch: | ||
description: 'Branch name we should watch for deployment' | ||
required: true | ||
|
||
#### | ||
outputs: | ||
env_status: | ||
description: "Final status of the PR environment" | ||
value: ${{ steps.get_env_url.outputs.env_status }} | ||
pr_url: | ||
description: "The URL of the PR environment" | ||
value: ${{ steps.get_env_url.outputs.env_url }} | ||
pr_url_upsun: | ||
description: "The URL of the Upsun variant of the PR environment" | ||
value: ${{ steps.get_env_url.outputs.env_url_upsun }} | ||
|
||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Set up Platform.sh CLI | ||
env: | ||
PLATFORMSH_CLI_TOKEN: ${{ inputs.platformsh_token }} | ||
uses: ./.github/actions/set-up-cli | ||
- name: Get environment URL | ||
shell: bash | ||
env: | ||
PLATFORMSH_CLI_TOKEN: ${{ inputs.platformsh_token }} | ||
BRANCH: ${{ inputs.branch }} | ||
UPSUN_DOCS_PREFIX: "https://docs.upsun.com" # @todo move to a repo var? | ||
id: get_env_url | ||
run: | | ||
COMMIT_STATUS="pending" | ||
# Get the state of the most recent deployment activity | ||
# run commands in workflows are are automatically launched with shell: /usr/bin/bash -e {0}. If for some | ||
# reason the psh cli errors (e.g. branch hasn't reached psh and therefore doesnt exist, api times out, etc) | ||
# this will cause our workflow to exit. Instead, call the cli with an | true so we can attempt to query again | ||
STATE=$(platform activities --format plain --type "environment.push environment.activate environment.redeploy environment.branch" --no-header --columns "state" --limit 1 --environment ${BRANCH} || true) | ||
echo "::notice::Attempting to retrieve deployed environment URL. Current state is: ${STATE}" | ||
# Set tries to 0 to start countdown to timeout | ||
STATUS_TRY=1 | ||
# We'll try up to 20 minutes, so (SLEEP_TIME*NUM_ATTEMPTS)/60 = 10* | ||
SLEEP_TIME=10 | ||
NUM_ATTEMPTS=120 | ||
# Wait until state is complete or 20 minutes has passed | ||
until [ "${STATE}" = "complete" ] || [ ${STATUS_TRY} = ${NUM_ATTEMPTS} ]; do | ||
sleep ${SLEEP_TIME} | ||
echo "::notice::Environment is not deployed. Attempting to retrieve deployed status. Attempt ${STATUS_TRY} of ${NUM_ATTEMPTS}." | ||
STATE=$(platform activities --format plain --type "environment.push environment.activate environment.redeploy environment.branch" --no-header --columns "state" --limit 1 --environment "${BRANCH}" || true) | ||
echo "::notice::Status retrieved: ${STATE}" | ||
if [ "${STATE}" = "complete" ]; then | ||
echo "::notice::Activity is complete." | ||
fi | ||
# we want to clear the cli cache every 3rd attempt in case it is caching too heavily | ||
if [ $(expr ${STATUS_TRY} % 3) = 0 ]; then | ||
echo "Clearing the cli cache..." | ||
platform clear-cache | ||
fi | ||
STATUS_TRY=$((++STATUS_TRY)) | ||
done | ||
# Get the URL of the environment | ||
ENV_URL=$(platform url --primary --pipe --environment "${BRANCH}") | ||
# Get the status of the build activity | ||
COMMIT_STATUS=$(platform activities --format plain --type "environment.push environment.activate environment.redeploy environment.branch" --no-header --columns "result" --limit 1 --environment "${BRANCH}") | ||
# Report findings | ||
echo "The Platform.sh environment is:" | ||
echo "$COMMIT_STATUS" | ||
if [ "$COMMIT_STATUS" = "success" ]; then | ||
echo "Environment deployed to:" | ||
echo "$ENV_URL" | ||
fi | ||
# Report the final statuses to be used in future jobs | ||
echo "env_status=$COMMIT_STATUS" >> $GITHUB_OUTPUT | ||
echo "env_url=$ENV_URL" >> $GITHUB_OUTPUT | ||
echo "env_url_upsun=${{ env.UPSUN_DOCS_PREFIX }}.${ENV_URL:8}" >> $GITHUB_OUTPUT |
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,14 @@ | ||
name: redirections contract verification | ||
description: Verifies that the redirections for our contract with console are still valid | ||
inputs: | ||
environment-url: | ||
description: 'Pull Request Environment URL' | ||
required: true | ||
|
||
#### | ||
#outputs: | ||
#### | ||
|
||
runs: | ||
using: 'node20' | ||
main: index.js |
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,89 @@ | ||
const core = require('@actions/core') | ||
const github = require('@actions/github') | ||
const fs = require('fs'); | ||
const yaml = require('js-yaml'); | ||
const axios = require('axios'); | ||
const tableData = [ | ||
[ | ||
{data: 'From', header: true}, | ||
{data: 'To', header: true} | ||
] | ||
] | ||
|
||
function linkify(path,url) { | ||
let link = "" | ||
|
||
/** | ||
* We only want to append the URL if the path doesnt already start with https | ||
*/ | ||
if (!path.startsWith('https:')) { | ||
if(url.endsWith('/')) { | ||
url = url.slice(0,-1); | ||
} | ||
|
||
link = url+path; | ||
|
||
} else { | ||
link = path; | ||
} | ||
|
||
return `<a href="${link}">${path}</a>` | ||
} | ||
|
||
/** | ||
* @todo should we verify that the URL is valid before we set it? | ||
* @type {string} | ||
*/ | ||
axios.defaults.baseURL = core.getInput('environment-url') | ||
|
||
try { | ||
/** | ||
* @todo Can we get the full workspace path to this file? | ||
* @type {*} | ||
*/ | ||
const yamlData = yaml.load(fs.readFileSync('./.platform/routes.yaml', 'utf8')); | ||
/** | ||
* @todo the key (docs.upsun.com) here should be a variable that is set somewhere else | ||
* @type {Record<string, string[]> | _.LodashAt | ((request: string) => (string[] | null)) | string[]} | ||
*/ | ||
const anchors = yamlData['https://docs.upsun.com/'].redirects.paths | ||
|
||
const RedirectKeys = Object.keys(anchors).filter((path)=>{ | ||
/** | ||
* @todo the piece we're using to identify our contracts (/anchors/) should be a variable | ||
*/ | ||
return path.startsWith('/anchors/') | ||
}) | ||
|
||
const validateRedirects = RedirectKeys.map(async (path, index, array) => { | ||
//console.log(`I'm going to test ${path} to see if it goes to ${anchors[path].to}`) | ||
|
||
try { | ||
const response = await axios.head(path); | ||
//core.info(`Response for our check of ${path} is ${response.status}`) | ||
return response | ||
} catch (reqerr) { | ||
//core.warning(`issue encountered with path ${path}!!! Returned status is ${reqerr.status}`) | ||
let row = [{data: linkify(path, axios.defaults.baseURL)},{data: linkify( anchors[path].to, axios.defaults.baseURL) }] | ||
tableData.push(row) | ||
} | ||
}); | ||
|
||
|
||
Promise.all(validateRedirects).then(() => { | ||
if(tableData.length > 1) { | ||
|
||
core.error('There was an error with one or more redirects.') | ||
|
||
core.summary.addTable(tableData) | ||
|
||
core.summary.write() | ||
core.setFailed('There was an error with one or more contracted redirects.') | ||
} else { | ||
core.notice('All contracted redirections are valid.') | ||
} | ||
}); | ||
|
||
} catch (error) { | ||
core.setFailed(`Action failed with error ${error}`) | ||
} |
9 changes: 9 additions & 0 deletions
9
.github/actions/redirection-verification/node_modules/@actions/core/LICENSE.md
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.