Skip to content
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
64 changes: 40 additions & 24 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,66 @@ on:
required: true
type: choice
options:
- Production
- Staging
# - Production
pull_request:

jobs:
setup:
name: Setup
find-env:
name: Find environment
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.set_env.outputs.environment }}
charm_changed: ${{ steps.check.outputs.charm_changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# change environment=Production for refs/head/main when it's set up
- name: Determine environment
id: set_env
run: |
if [[ -n "${{ github.event.inputs.environment }}" ]]; then
echo "environment=${{ github.event.inputs.environment }}" >> "$GITHUB_OUTPUT"
elif [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
echo "environment=Staging" >> "$GITHUB_OUTPUT"
echo "target_ref=refs/remotes/origin/main" >> "$GITHUB_OUTPUT"
echo "environment=Production" >> "$GITHUB_OUTPUT"
else
echo "environment=Staging" >> "$GITHUB_OUTPUT"
echo "target_ref=refs/remotes/origin/staging" >> "$GITHUB_OUTPUT"
fi

- name: Check for charm/ changes
id: check
setup:
name: Setup
runs-on: ubuntu-latest
needs: find-env
environment: ${{ needs.find-env.outputs.environment }}
outputs:
environment: ${{ steps.set.outputs.environment }}
environment_url: ${{ steps.set.outputs.environment_url }}
charm_name: ${{ steps.set.outputs.charm_name }}
channel: ${{ steps.set.outputs.channel }}
juju_controller_name: ${{ steps.set.outputs.juju_controller_name }}
juju_model_name: ${{ steps.set.outputs.juju_model_name }}
steps:
- id: set
run: |
ls -l .git/refs
ls -l .git/refs/heads
ls -l .git/refs/remotes/origin
echo "${GITHUB_REF}"
git diff --name-only ${{ steps.set_env.outputs.target_ref }} ${{ github.sha }} | cat
if [[ $(git diff --name-only ${{ steps.set_env.outputs.target_ref }} ${{ github.sha }} | grep '^charm/') ]]; then
echo "charm_changed=true" >> "$GITHUB_OUTPUT"
else
echo "charm_changed=false" >> "$GITHUB_OUTPUT"
fi

- name: Test outputs
run: echo "${{ steps.set_env.outputs.environment }}" && echo "${{ steps.set_env.outputs.target_ref }}" && echo "${{ steps.check.outputs.charm_changed }}"
echo "environment=${{ needs.find-env.outputs.environment }}" >> "$GITHUB_OUTPUT"
echo "environment_url=${{ vars.ENVIRONMENT_URL }}" >> "$GITHUB_OUTPUT"
echo "charm_name=${{ vars.CHARM_NAME }}" >> "$GITHUB_OUTPUT"
echo "channel=${{ vars.CHANNEL }}" >> "$GITHUB_OUTPUT"
echo "juju_controller_name=${{ vars.JUJU_CONTROLLER_NAME }}" >> "$GITHUB_OUTPUT"
echo "juju_model_name=${{ vars.JUJU_MODEL_NAME }}" >> "$GITHUB_OUTPUT"

deploy:
needs: setup
name: Deploy
uses: canonical/webteam-devops/.github/workflows/deploy.yaml@v1
with:
environment: ${{ needs.setup.outputs.environment }}
environment_url: ${{ needs.setup.outputs.environment_url }}
charm_name: ${{ needs.setup.outputs.charm_name }}
channel: ${{ needs.setup.outputs.channel }}
juju_controller_name: ${{ needs.setup.outputs.juju_controller_name }}
juju_model_name: ${{ needs.setup.outputs.juju_model_name }}
secrets:
VAULT_APPROLE_ROLE_ID: ${{ secrets.VAULT_APPROLE_ROLE_ID }}
VAULT_APPROLE_SECRET_ID: ${{ secrets.VAULT_APPROLE_SECRET_ID }}
CHARMHUB_TOKEN: ${{ secrets.CHARMHUB_TOKEN }}
54 changes: 0 additions & 54 deletions .github/workflows/juju_deploy.yaml

This file was deleted.

21 changes: 10 additions & 11 deletions charm/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ name: rockstore-io

type: charm

bases:
- build-on:
- name: ubuntu
channel: "22.04"
run-on:
- name: ubuntu
channel: "22.04"

summary: The charm for rockstore.io
base: ubuntu@22.04
platforms:
amd64:

title: Rocks store
summary: Charm for the Rocks Store
description: |
This is the charmed rockstore.io. This charm deploys the rockstore.io
This is the charmed Rocks Store. This charm deploys the rocks
storefront. It is a web application that allows users to view rocks.
Test -> Delete after
links:
contact: luke.wesley-holley@canonical.com
website:
- https://rocks.ubuntu.com

extensions:
- flask-framework
33 changes: 33 additions & 0 deletions konf/site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is currently used by Demos (Jenkins)
# It is not used in ProdStack 6 and greater
# Do not remove it

domain: rockstore.io

image: prod-comms.ps5.docker-registry.canonical.com/rockstore.io

env:
- name: MAINTENANCE
configMapKeyRef:
key: maintenance
name: rockstore

- name: ENVIRONMENT
configMapKeyRef:
key: environment
name: environment

# TODO: update with proper domains
extraHosts:
- domain: jujucharms.com
- domain: openoperatorcollection.io

# Overrides for staging environment
staging:
replicas: 3
nginxConfigurationSnippet: |
if ($host != 'staging.rockstore.io' ) {
rewrite ^ https://staging.rockstore.io$request_uri? permanent;
}
more_set_headers "X-Robots-Tag: noindex";
more_set_headers "Link: <https://assets.ubuntu.com>; rel=preconnect; crossorigin, <https://assets.ubuntu.com>; rel=preconnect, <https://res.cloudinary.com>; rel=preconnect";
19 changes: 18 additions & 1 deletion rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
name: rockstore-io
base: ubuntu@22.04
version: "0.1"
summary: This is the rocked rockstore.io
description: |
This is the rocked rocks storefront.

base: bare
build-base: ubuntu@22.04
platforms:
amd64:

extensions:
- flask-framework

parts:
build-ui:
plugin: nil
source: .
source-type: local
build-snaps:
- node/22/stable
override-build: |
set -eux
# install dependencies
npm install -g yarn
yarn install
# build the UI
yarn run build
mkdir -p "$CRAFT_PART_INSTALL/flask/app"
cp -r static "$CRAFT_PART_INSTALL/flask/app/"
flask-framework/install-app:
prime:
- flask/app/.env
Expand Down