Thank-you Golden Edition #80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MilkBasket Deploy | |
env: | |
project: MilkBasket | |
server: https://cyberboy.octopus.app/ | |
version: $(date +%Y.%m.%d).i | |
on: | |
push: | |
branches: master | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Octopus Command-Line Interface | |
run: sudo apt update && sudo apt install --no-install-recommends gnupg curl ca-certificates jq apt-transport-https && | |
curl -sSfL https://apt.octopus.com/public.key | sudo apt-key add - && | |
sudo sh -c "echo deb https://apt.octopus.com/ stable main > /etc/apt/sources.list.d/octopus.com.list" && | |
sudo apt update && sudo apt install octopuscli | |
- name: Create Octopus release | |
run: | | |
octo create-release --server ${{ env.server }} --apiKey ${{ secrets.OCTOPUS_API_KEY }} --project ${{ env.project }} --version ${{ env.version }} | |
- name: Deploy to environment | |
run: | | |
octo deploy-release --server ${{ env.server }} --apiKey ${{ secrets.OCTOPUS_API_KEY }} --project ${{ env.project }} --version=latest --deployTo Production | |
- name: Wait 60 Sec to complete the deploy | |
run: | | |
sleep 60 | |
- name: Get latest release version from Octopus | |
id: octopus | |
run: | | |
release_metadata=$(octo list-latestDeployments --server=${{ env.server }} --project="MilkBasket" --environment="Production" --apikey=${{ secrets.OCTOPUS_API_KEY }} --space="milk-space" --outputFormat=json | tail -n +2 | jq -r '.[0].Version') | |
echo "::set-output name=release-version::$release_metadata" | |
release_metadata=$(octo list-latestDeployments --server=${{ env.server }} --project="MilkBasket" --environment="Production" --apikey=${{ secrets.OCTOPUS_API_KEY }} --space="milk-space" --outputFormat=json | tail -n +2 | jq -r '.[0].Assembled') | |
echo "::set-output name=assembled::$release_metadata" | |
release_metadata=$(octo list-latestDeployments --server=${{ env.server }} --project="MilkBasket" --environment="Production" --apikey=${{ secrets.OCTOPUS_API_KEY }} --space="milk-space" --outputFormat=json | tail -n +2 | jq -r '.[0].State') | |
echo "::set-output name=state::$release_metadata" | |
release_metadata=$(octo list-latestDeployments --server=${{ env.server }} --project="MilkBasket" --environment="Production" --apikey=${{ secrets.OCTOPUS_API_KEY }} --space="milk-space" --outputFormat=json | tail -n +2 | jq -r '.[0].Duration') | |
echo "::set-output name=duration::$release_metadata" | |
- name: Create GitHub release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ steps.octopus.outputs.release-version }} | |
release_name: MilkBasket-${{ steps.octopus.outputs.release-version }} | |
body: | | |
Release Info: | |
MilkBasket Release Version: ${{ steps.octopus.outputs.release-version }} | |
Assembled: ${{ steps.octopus.outputs.assembled }} | |
State: ${{ steps.octopus.outputs.state }} | |
Duration: ${{ steps.octopus.outputs.duration }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} |