diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 74c08b9..5c24a33 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,6 +14,9 @@ on: 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 @@ -42,17 +45,24 @@ jobs: 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 ${{ inputs.version == '' }}; then + 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: 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: Info id: skpr-info shell: bash @@ -65,5 +75,6 @@ jobs: run: skpr package ${{ steps.version.outputs.version }} - name: Deploy run: skpr deploy ${{ inputs.env }} ${{ steps.version.outputs.version }} - - name: Post-deploy Commands + - name: Post-deploy run: skpr exec ${{ inputs.env }} ${{ inputs.post_deploy }} + - run: echo "::notice:: Deployed ${{ steps.version.outputs.version }}"