Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 57 additions & 18 deletions .github/workflows/bikes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ on:
jobs:
build:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@master

- uses: azure/docker-login@releases/v1
steps:
- uses: actions/checkout@master

- uses: azure/docker-login@v1
with:
login-server: ${{ secrets.CONTAINER_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
Expand All @@ -29,32 +28,72 @@ jobs:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: ${{ secrets.CLUSTER_NAME }}
resource-group: ${{ secrets.RESOURCE_GROUP }}


- name: Create valid child namespace name
id: generate-child-space-name
run: |
branch=${GITHUB_HEAD_REF::63}
branch=$(echo ${branch//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed -e 's/^-/z/' -e 's/-$/z/')
echo ::set-output name=result::$branch

- name: Create child namespaces and add Dev Spaces labels
run: |
if [ -n "$(kubectl get namespace $GITHUB_HEAD_REF --ignore-not-found -o name)" ]; then exit 0; fi
kubectl create namespace $GITHUB_HEAD_REF
kubectl label namespace $GITHUB_HEAD_REF azds.io/parent-space=${{ secrets.MASTER_SPACE }}
kubectl label namespace $GITHUB_HEAD_REF azds.io/space=true
kubectl label namespace $GITHUB_HEAD_REF azds.io/pull-request-space=true
if [ -n "$(kubectl get namespace ${{steps.generate-child-space-name.outputs.result}} --ignore-not-found -o name)" ]; then exit 0; fi
kubectl create namespace ${{steps.generate-child-space-name.outputs.result}} \
kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} \
azds.io/parent-space=${{ secrets.MASTER_SPACE }} \
azds.io/space=true \
azds.io/pull-request-space=true

- uses: azure/k8s-actions/k8s-create-secret@master
with:
namespace: ${{ github.head_ref }}
namespace: ${{ steps.generate-child-space-name.outputs.result }}
container-registry-url: ${{ secrets.CONTAINER_REGISTRY }}
container-registry-username: ${{ secrets.REGISTRY_USERNAME }}
container-registry-password: ${{ secrets.REGISTRY_PASSWORD }}
secret-name: ${{ secrets.IMAGE_PULL_SECRET }}

- name: Helm Install PR

- name: Create valid release-name
id: generate-release-name
run: |
helm init --upgrade --wait
helm upgrade --install --namespace $GITHUB_HEAD_REF bikesharing-$GITHUB_HEAD_REF samples/BikeSharingApp/Bikes/charts/bikes \
release=bikesharing-$GITHUB_HEAD_REF
release=${release::53}
release=$(echo ${release//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed -e 's/^-/z/' -e 's/-$/z/')
echo ::set-output name=result::$release

- name: Install Helm for client
id: install-helm-client
run: |
set -e
clientversion=$(helm version --client --short | cut -d' ' -f2 | cut -d'+' -f1)
serverversion=$(helm version --server --short | cut -d' ' -f2 | cut -d'+' -f1)
if [ ! -n "$serverversion" ]; then
echo "Please install Helm on the server!" 1>&2
exit 1
elif [ "$clientversion" == "$serverversion" ]; then
echo The client and server Helm Versions are equal
echo ::set-output name=helm::helm
else
tmp_dir=$(mktemp -d)
export DESIRED_VERSION=$serverversion HELM_INSTALL_DIR=$tmp_dir
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh
echo ::set-output name=helm::$tmp_dir/helm
fi

- name: Helm Upgrade PR
run: |
${{steps.install-helm-client.outputs.helm}} upgrade \
--install ${{steps.generate-release-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \
--namespace ${{steps.generate-child-space-name.outputs.result}} \
--set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \
--set image.tag=$GITHUB_SHA \
--set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }}

- uses: azure/dev-spaces/actions/add-review-url@Releases/v1
- uses: azure/dev-spaces/actions/add-review-url@Releases/v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
host: ${{ secrets.HOST }}
host: ${{ secrets.HOST }}
child-space: ${{steps.generate-child-space-name.outputs.result}}
protocol: 'http'
2 changes: 1 addition & 1 deletion .github/workflows/bikesharing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/checkout@master

- uses: azure/docker-login@releases/v1
- uses: azure/container-actions/docker-login@master
with:
login-server: ${{ secrets.CONTAINER_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
Expand Down
8 changes: 7 additions & 1 deletion actions/add-review-url/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ inputs:
required: true
host: # Complete host.
description: "Complete host. This expands to: [rootSpace.]webfrontend.<random suffix>.<region>.azds.io. For more information see https://aka.ms/devspaces/routing"
required: true
required: true
child-space: # Child space.
description: "This is the child namespace name passed in from the workflow to construct the uri."
required: true
protocol: # This is an optional parameter that the user can specify (http vs https)
description: "This is an optional parameter that the user can specify: example values - http or https"
required: false
runs:
using: 'node12'
main: 'lib/index.js'
5 changes: 3 additions & 2 deletions actions/add-review-url/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ function run() {
const addComment = new AddReviewUrl_1.default();
try {
const host = core.getInput('host');
let headref = process.env.GITHUB_HEAD_REF || '';
const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`;
let headref = core.getInput('child-space') || '';
let protocol = core.getInput('protocol') || 'http';
const comment = `You can see a private version of the changes made in this pull request here:\n${protocol}://${headref}.s.${host}/`;
yield addComment.addComment(comment);
}
catch (error) {
Expand Down
5 changes: 3 additions & 2 deletions actions/add-review-url/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ async function run() {
const addComment = new AddComment();
try {
const host = core.getInput('host');
let headref = process.env.GITHUB_HEAD_REF || '';
const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`;
let headref = core.getInput('child-space') || '';
let protocol = core.getInput('protocol') || 'http';
const comment = `You can see a private version of the changes made in this pull request here:\n${protocol}://${headref}.s.${host}/`;
await addComment.addComment(comment);
}catch (error) {
core.setFailed(error.message);
Expand Down