Skip to content

Commit

Permalink
[WIP] workflows: run tag and build in one workflow
Browse files Browse the repository at this point in the history
GitHub workflows are limited in that a workflow (here: tag) can not
trigger another workflow (here: build).

Both worked independently, yet the build workflow running "on" tag
"create" would only run upon push, not when the other worfklow created a
tag via the GitHub script.

To avoid managing personal access tokens, which would allow this, the
actions are merged into one.

The tag name is change to be more generic.

https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow#triggering-a-workflow-from-a-workflow
  • Loading branch information
thlehmann-ionos committed Oct 30, 2024
1 parent 3c42880 commit 8056f5d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 49 deletions.
41 changes: 34 additions & 7 deletions .github/workflows/easycloud-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,46 @@ on:
- '**.js'
- '**.ts'
- '**.vue'
create:
tags:
- v1*
- v2*
- v3*
- snap-*
push:
branches:
# Enable once approved
# - ionos-dev
- tl/workflow-build-snapshots-with-releases

env:
PACKAGE_NAME_PREFIX: easy-storage
PACKAGE_NAME_EXTENSION: zip

jobs:
# Having a tag is necessary to create a release otherwise this error is thrown:
# "⚠️ GitHub Releases requires a tag"
snapshot-tag:
runs-on: ubuntu-latest

permissions:
contents: write

name: snapshot-tag
steps:
- name: Create tag
uses: actions/github-script@v7
with:
# https://octokit.github.io/rest.js/v21/#git-create-tag
script: |
const dateStr = new Date()
.toISOString()
.replace(/^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+).*$/, "$1$2$3-$4$5$6");
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
message: 'Snapshot build',
ref: `refs/tags/rel-${dateStr}`,
sha: context.sha
});
# Build and create release
#
easycloud-build:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -97,7 +125,6 @@ jobs:

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ env.PACKAGE_NAME }}

Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/tag-snapshot.yml

This file was deleted.

0 comments on commit 8056f5d

Please sign in to comment.