Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds deploy workflow #1

Merged
merged 18 commits into from
Sep 20, 2023
22 changes: 22 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: actionlint
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

jobs:
run-actionlint:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- name: actionlint
uses: raven-actions/actionlint@v1
with:
shellcheck: false
pyflakes: false
80 changes: 80 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Skpr Deploy

on:
workflow_call:
inputs:
env:
type: string
required: true
description: The Skpr environment to deploy to.
package:
default: true
type: boolean
description: Whether this deployment needs to be packaged.
version:
type: string
description: The version to deploy
version_from_env:
type: string
description: Get the version to deploy from the environment.
post_deploy:
default: make deploy
type: string
description: The post deploy commands to run on the environment.
secrets:
skpr_username:
required: true
skpr_password:
required: true

env:
SKPR_USERNAME: ${{ secrets.SKPR_USERNAME }}
SKPR_PASSWORD: ${{ secrets.SKPR_PASSWORD }}
GH_TOKEN: ${{ github.token }}

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ inputs.env }}
url: ${{ steps.skpr-info.outputs.url }}
concurrency: ${{ inputs.env }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- name: Install Skpr CLI
run: |
gh release download --repo skpr/cli --pattern skpr_*_linux_amd64.deb -O skpr-cli.deb
sudo dpkg -i skpr-cli.deb
- name: Get version
id: version
run: |
if [ -n "${{ inputs.version }}" ]; then
version=${{ inputs.version }}
echo "::notice:: Using explicit version $version"
elif [ -n "${{ inputs.version_from_env }}" ]; then
version=$(skpr info ${{ inputs.version_from_env }} | jq -r ".Version")
echo "::notice:: Using version $version from ${{ inputs.version_from_env }} env"
else
version=$(git describe --tags --always)
echo "::notice:: Using version $version from git describe"
fi
echo "version=$version" >> $GITHUB_OUTPUT
- name: Info
id: skpr-info
shell: bash
run: |
domain=$(skpr info ${{ inputs.env }} | jq -r ".Ingress.Domain")
url=https://$domain
echo "url=$url" >> $GITHUB_OUTPUT
- name: Package
if: inputs.package
run: skpr package ${{ steps.version.outputs.version }}
- name: Deploy
run: skpr deploy ${{ inputs.env }} ${{ steps.version.outputs.version }}
- name: Post-deploy
run: skpr exec ${{ inputs.env }} ${{ inputs.post_deploy }}