Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sevensolutions committed Oct 6, 2024
2 parents 77e893e + c709b21 commit 118d56d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ jobs:
with:
dotnet-version: 8.0.x

# Extract and publish version
- name: extract version
run: |
Get-Content "./src/NomadIIS/PluginInfo.cs" | Select-String 'public static readonly string Version = "([0-9]+\.[0-9]+\.[0-9])";' | ForEach-Object {
$version = $_.Matches[0].Groups[1].Value
}
$version | Out-File -Path version -NoNewline
- name: Upload version
if: ${{ matrix.profile.artifactName == 'nomad_iis' }} # We only need to do this once
uses: actions/upload-artifact@v4
with:
name: version
path: ./version

# Publish the application
- name: Publish the application
run: dotnet publish "./src/NomadIIS/NomadIIS.csproj" /p:PublishProfile="./src/NomadIIS/Properties/PublishProfiles/${{ matrix.profile.publishProfile }}"
Expand Down
43 changes: 39 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,51 @@ on:
runId:
description: "The id of the workflow run to create the release from"
required: true
version:
description: "The version for the release"
required: true

permissions:
contents: write

jobs:
build:
release:
runs-on: ubuntu-latest

steps:
# Download artifacts
- uses: actions/download-artifact@master
with:
name: version
path: version # Note: This downloads into a folder "version"
github-token: ${{ github.token }}
run-id: ${{ github.event.inputs.runId }}
- uses: actions/download-artifact@master
with:
name: nomad_iis
path: nomad_iis
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ github.token }}
run-id: ${{ github.event.inputs.runId }}
- uses: actions/download-artifact@master
with:
name: nomad_iis_mgmt_api
path: nomad_iis_mgmt_api
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ github.token }}
run-id: ${{ github.event.inputs.runId }}

# Read version
- name: read and verify version
run: |
version=`cat ./version/version`
echo "Release Version: ${{ github.event.inputs.version }}"
echo "Version in Build: ${version}"
if [ "${{ github.event.inputs.version }}" != "${version}" ]
then
echo "The specified release version doesn't match the version in the build. Please update PluginInfo.cs first."
exit 1
fi
# Zip the artifacts
- uses: vimtor/action-zip@v1.2
with:
Expand All @@ -35,4 +60,14 @@ jobs:
with:
files: ./nomad_iis_mgmt_api
dest: nomad_iis_mgmt_api.zip


# Create the Release
- name: create release
uses: softprops/action-gh-release@v2
with:
name: v${{ github.event.inputs.version }}
tag_name: v${{ github.event.inputs.version }}
draft: true
files: |
nomad_iis.zip
nomad_iis_mgmt_api.zip
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Feel free to use it as-is or as a reference implementation for your own C#-based
| Multiple Applications || Support for multiple sub-applications below the website. |
| Virtual Directories || Support for multiple *virtual directories* below an application. |
| HTTP Bindings || |
| HTTPS Bindings || [GH-3](https://github.com/sevensolutions/nomad-iis/issues/3) |
| HTTPS Bindings || [Details](https://nomad-iis.sevensolutions.cc/docs/tips-and-tricks/working-with-certificates) |
| Environment Variables || [Details](https://nomad-iis.sevensolutions.cc/docs/features/environment-variables) |
| Resource Statistics || |
| Logging || Experimental UDP logging. See [GH-6](https://github.com/sevensolutions/nomad-iis/issues/6) for details. |
Expand Down
34 changes: 34 additions & 0 deletions tools/deleteOldPagesDeployments.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

accountId="TODO"
apiKey="TODO"

jsonData=$(curl -sS --request GET \
--url https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/nomad-iis/deployments \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${apiKey}")

for i in $(seq 0 $(($(jq '.result | length' <<< "$jsonData") - 1))); do
# Extract each property from the JSON
id=$(jq -r ".result[$i].id" <<< "$jsonData")
environment=$(jq -r ".result[$i].environment" <<< "$jsonData")
aliasCount=$(jq -r ".result[$i].aliases | length" <<< "$jsonData")
branchName=$(jq -r ".result[$i].deployment_trigger.metadata.branch" <<< "$jsonData")

if [ "${environment}" == "preview" ] && [[ "${branchName}" == feature/* ]] && [ $aliasCount == 0 ]
then
# Print the extracted information
echo ""
echo "Id: $id"
echo "Environment: $environment"
echo "Branch: ${branchName}"
echo "Alias Count: ${aliasCount}"

read -p "Press enter to delete... " -n1 -s

curl --request DELETE \
--url https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/nomad-iis/deployments/${id} \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${apiKey}"
fi
done

0 comments on commit 118d56d

Please sign in to comment.