Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing GH actions, to use less minutes. (WIP) #1563

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@ env:
PHP_VERSION: 8.1
COMPOSER_VERSION: v2

# Detect if this action is already running, and cancel it.
# This most likely happened because a second push has been made to a branch.
concurrency:
group: ${{ github.repository_id }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
BranchNameLength:
name: Check branch length
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Ensure branch name length
uses: lekterable/branchlint-action@2.1.0
if: github.ref_type == 'branch' || github.ref_type == 'pull_request'
with:
allowed: |
/^.{1,100}$/
errorMessage: 'Branch name too long. This cannot be deployed to Lagoon.'
Comment on lines +15 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we keep the Lagoon workflow around then I suggest moving this job back.


ValidateComposer:
name: Validate Composer
runs-on: ubuntu-latest
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/lagoon-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
name: "Tests of deployment"

on:
deployment_status

# @todo - this action does nothing useful right now, but it is to show that
# the site URL is available as part of deployment_status.
Comment on lines +7 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the comment but I suggest removing this file entirely.

As I see it we should not run tests on the deployed environment as implied in the workflow name. We do this on the corresponding environment established in CI.

jobs:
tests:
if: github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
steps:
- run: echo "$URL"
env:
URL: ${{ github.event.deployment_status.target_url }}
130 changes: 0 additions & 130 deletions .github/workflows/lagoon.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .lagoon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ project: dpl-cms-core

ssh: 20.238.147.183:22
api: https://api.lagoon.dplplat01.dpl.reload.dk/graphql
environment_variables:
git_sha: 'true'

tasks:
post-rollout:
- run:
name: Create new GH deployment
command: |
# @TODO Where can i place the token as a secret?
achton marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider mentioning that we do not use set -e as we do not want the build process to stop if deployment handling fails.

export GH_DEPLOYMENT_TOKEN = 'XXX';
export GH_DEPLOYMENT_ID = $(curl -L \
-X POST \
-H "Authorization: Bearer $GH_DEPLOYMENT_TOKEN" \
https://api.github.com/repos/danskernesdigitalebibliotek/dpl-cms/deployments \
-d '{"ref":"$LAGOON_GIT_SHA","description":"Triggered by Lagoon"}');
- run:
name: If drupal is not installed
command: |
Expand Down Expand Up @@ -92,7 +104,19 @@ tasks:
set -e
drush en -y dpl_example_content
service: cli
# @TODO How do we run this, even if something has gone wrong?
- run:
name: Setting Deployment status
command: |
# @TODO How do we set this to 'failure', if something has gone wrong?
DEPLOYMENT_STATUS="success";
Comment on lines +107 to +112
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


DRUPAL_URL=$(drush browse);
export GH_DEPLOYMENT_ID = $(curl -L \
-X POST \
-H "Authorization: Bearer $GH_DEPLOYMENT_TOKEN" \
https://api.github.com/repos/danskernesdigitalebibliotek/dpl-cms/deployments/$GH_DEPLOYMENT_ID/statuses \
-d '{"environment":"$LAGOON_GIT_SHA","state":"$DEPLOYMENT_STATUS", "target_url":"$DRUPAL_URL"}');
environments:
main:
cronjobs:
Expand Down
Loading