-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from xenit-eu/ALFREDAPI-552
Merge bypass due 23x builds not yet applying to this PR.
- Loading branch information
Showing
9 changed files
with
149 additions
and
41 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: 'Publish website' | ||
on: | ||
workflow_dispatch: | ||
env: | ||
BRANCH_NAME: ${{ github.ref_name }} | ||
ALFRESCO_NEXUS_USERNAME: ${{ secrets.ALFRESCO_NEXUS_USERNAME }} | ||
ALFRESCO_NEXUS_PASSWORD: ${{ secrets.ALFRESCO_NEXUS_PASSWORD }} | ||
jobs: | ||
alfred-api-docs: | ||
if: ${{ startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/release') }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
- name: Login to Docker | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: private.docker.xenit.eu | ||
username: ${{ secrets.CLOUDSMITH_USER }} | ||
password: ${{ secrets.CLOUDSMITH_APIKEY }} | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
- name: Build website | ||
run: ./gradlew :docs:buildWebsiteScript --info | ||
- name: Upload website artifact | ||
if: success() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: website-alfred-api.tar.gz | ||
path: /home/runner/work/alfred-api/docs/build/website-*.tar.gz | ||
retention-days: 2 | ||
- name: Write ssh key to file | ||
env: | ||
RAW_KEY: ${{ secrets.A2_HOSTING_SSH_KEY }} | ||
run: | | ||
mkdir -p /home/runner/.ssh/ | ||
echo "$RAW_KEY" > /home/runner/.ssh/a2hostingKey | ||
chmod 600 /home/runner/.ssh/a2hostingKey | ||
- name: Deploy tar to webhost | ||
env: | ||
GRADLE_OPTS: >- | ||
-Dorg.gradle.project.webHostAddress=nl1-ts102.a2hosting.com | ||
-Dorg.gradle.project.webHostPort=7822 | ||
-Dorg.gradle.project.webHostUser=xeniteu | ||
-Dorg.gradle.project.webHostSshKey=/home/runner/.ssh/a2hostingKey | ||
run: ./gradlew :docs:deployWebsiteToWebHost --info |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import java.text.SimpleDateFormat | ||
|
||
plugins { | ||
id "base" | ||
id "org.hidetake.ssh" version "2.11.2" | ||
} | ||
|
||
def date = new Date() | ||
def format = new SimpleDateFormat("yyyy-MM-dd") | ||
|
||
tasks.register("buildWebsiteScript", Exec) { | ||
setGroup "documentation" | ||
commandLine 'bash', './build-website.sh' | ||
} | ||
assemble.dependsOn buildWebsiteScript | ||
|
||
remotes { | ||
a2hosting { | ||
host = project.findProperty("webHostAddress") | ||
port = project.hasProperty("webHostPort") ? (project.getProperty("webHostPort") as Integer) : 22 | ||
user = project.findProperty("webHostUser") | ||
def keyFileLocation = project.hasProperty("webHostSshKey") ? project.getProperty("webHostSshKey") : "No Key" | ||
identity = file(keyFileLocation) | ||
} | ||
} | ||
|
||
ssh.settings { | ||
knownHosts = allowAnyHosts | ||
} | ||
|
||
tasks.register("deployWebsiteToWebHost") { | ||
setGroup "publishing" | ||
dependsOn buildWebsiteScript | ||
doLast { | ||
ssh.run { | ||
session(remotes.a2hosting) { | ||
def remoteHomeDir = execute 'pwd' | ||
def websiteDir = "${remoteHomeDir}/docs.xenit.eu" | ||
def today = format.format(date) | ||
def websiteTar = "website-alfred-api_${today}.tar.gz" | ||
def backupDir = "alfred-api_${today}_back" | ||
// Upload | ||
put from: file("${layout.buildDirectory.get()}/${websiteTar}"), into: "${websiteDir}/" | ||
// Backup old website component to tar | ||
execute "mv ${websiteDir}/alfred-api ${remoteHomeDir}/${backupDir}" | ||
execute "tar vczf alfred-api_${today}_back.tar.gz -C ${remoteHomeDir} ${backupDir}" | ||
// Deploy new website component from tar | ||
execute "tar vxzf ${websiteDir}/${websiteTar} -C ${websiteDir}" | ||
// Cleanup uncompressed backup | ||
remove "${remoteHomeDir}/${backupDir}" | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.