Skip to content

Commit

Permalink
refactor: manually update staging version
Browse files Browse the repository at this point in the history
  • Loading branch information
victorggonzalez committed Sep 3, 2022
1 parent 5d70ef1 commit 8c874d8
Showing 1 changed file with 29 additions and 36 deletions.
65 changes: 29 additions & 36 deletions .github/workflows/update-staging-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,35 @@
# with the repository name and the latest tag pushed from the caller repository.
name: Push new tag to graasp-deploy repository

# Controls when the action will run.
# Controls when the action will run
on:
# Triggers the workflow on push tag events.
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
# Allow the workflow to be manually triggered
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
release-type:
# Description to be shown in the UI instead of 'stack'
description: 'Select a release type'
# Default value if no value is explicitly provided
# Input does not have to be provided for the workflow to run
type: choice
options:
- first
- patch
- minor
- major
default: patch
required: true

# This workflow is made up of one job called dispatch
# This workflow is made up of one job that calls the reusable workflow in graasp-deploy
jobs:
# Create a json with the repository name and tag and pass it to graasp-deploy repository
dispatch:
name: Update staging versions
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Check-out repository under $GITHUB_WORKSPACE, so the job can access it
- name: Check out code
uses: actions/checkout@v2

# Get the latest tag and create a json with the repository name and tag
# ::set-output name={name}::{value} Sets an output parameter for this step.
- name: Set tag
id: set-tag
run: |
COMMIT=$(git rev-list --tags --max-count=1)
TAG=$(git describe --tags $COMMIT)
REPOSITORY=$(echo '${{ github.repository }}')
JSON=$(jq --null-input --arg repository "$REPOSITORY" --arg tag "$TAG" '{"repository": $repository, "tag": $tag}')
echo ::set-output name=json::${JSON//'%'/'%25'}
# trigger an 'on: repository_dispatch' workflow to run in graasp-deploy repository
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: graasp/graasp-deploy
event-type: update-staging-version
client-payload: ${{steps.set-tag.outputs.json}}
graasp-deploy-update-staging-version-workflow:
# Replace with repository name
name: Graasp app file-drop
# Replace 'main' with the hash of a commit, so it points to an specific version of the reusable workflow that is used
# Reference reusable workflow file. Using the commit SHA is the safest for stability and security
uses: graasp/graasp-deploy/.github/workflows/update-staging-version.yml@2c1fbb283ea5db70258237bb0fe0fd1a09064861
with:
release-type: ${{ inputs.release-type }}
secrets:
token: ${{ secrets.REPO_ACCESS_TOKEN }}

0 comments on commit 8c874d8

Please sign in to comment.