Skip to content

Deploy

Deploy #1989

Workflow file for this run

name: Deploy
on:
workflow_run:
workflows: ["Build & test"]
types:
- completed
concurrency:
group: deploy
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-20.04
if: >-
${{ github.event.workflow_run.conclusion == 'success' && (
github.actor == 'LukasKalbertodt' ||
github.actor == 'JulianKniephoff' ||
github.actor == 'owi92' ||
github.actor == 'lkiesow'
) }}
steps:
- uses: actions/checkout@v3
# Unfortunately we cannot use `actions/download-artifact` here since that
# only allows to download artifacts from the same run.
- name: Download artifacts from build workflow
uses: actions/github-script@v6
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const deployFiles = artifacts.data.artifacts
.filter(a => a.name == "test-deployment-files")[0];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: deployFiles.id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{github.workspace}}/artifacts.zip', Buffer.from(download.data));
// The artifact is not needed anymore
github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: deployFiles.id,
})
- name: extract artifacts
run: mkdir tmp_artifacts && unzip artifacts.zip -d tmp_artifacts
- name: Read Deploy ID
run: echo "DEPLOY_ID=$(cat ./tmp_artifacts/deploy-id)" >> $GITHUB_ENV
- name: Set GitHub deployment status to "Pending"
uses: bobheadxi/[email protected]
id: gh_deployment_start
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: test-deployment-${{ env.DEPLOY_ID }}
ref: ${{ github.event.workflow_run.head_commit.id }}
- name: Prepare files for deployment
run: |
cp -v tmp_artifacts/tobira .deployment/files/
cp -v tmp_artifacts/util/dev-config/logo-large.svg .deployment/files/
cp -v tmp_artifacts/util/dev-config/logo-small.svg .deployment/files/
cp -v tmp_artifacts/util/dev-config/logo-large-dark.svg .deployment/files/
cp -v tmp_artifacts/util/dev-config/favicon.svg .deployment/files/
cp -v tmp_artifacts/.deployment/templates/config.toml .deployment/templates/config.toml
cp -v tmp_artifacts/util/dummy-login/dist/index.js .deployment/files/login-handler.js
- name: prepare deploy key
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
install -dm 700 ~/.ssh/
echo "${DEPLOY_KEY}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan tobira.opencast.org >> ~/.ssh/known_hosts
- name: install ansible postgres extensions
run: ansible-galaxy collection install community.postgresql
- name: deploy tobira branch
working-directory: .deployment
env:
OPENCAST_ADMIN_PASSWORD: ${{ secrets.TOBIRA_OPENCAST_ADMIN_PASSWORD }}
run: >
ansible-playbook
--private-key=~/.ssh/id_ed25519
--extra-vars="deployid='${{ env.DEPLOY_ID }}'"
-u github
deploy.yml
- name: Set GitHub deployment status to "deployed"
uses: bobheadxi/[email protected]
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
env: test-deployment-${{ env.DEPLOY_ID }}
status: ${{ job.status }}
deployment_id: ${{ steps.gh_deployment_start.outputs.deployment_id }}
env_url: ${{ format('https://{0}.tobira.opencast.org', env.DEPLOY_ID) }}