Skip to content

Merge pull request #42 from canonical/main #24

Merge pull request #42 from canonical/main

Merge pull request #42 from canonical/main #24

Workflow file for this run

name: Pack and Deploy
on:
push:
branches:
- main
- staging
workflow_dispatch:
inputs:
environment:
description: 'Environment (Production or Staging)'
required: true
type: choice
options:
- Staging
# - Production
pull_request:
jobs:
setup:
name: Setup
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"
else
echo "environment=Staging" >> "$GITHUB_OUTPUT"
echo "target_ref=refs/remotes/origin/staging" >> "$GITHUB_OUTPUT"
fi
- name: Check for charm/ changes
id: check
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 }}"