|
name: Get Previous Release Tag |
|
|
|
on: |
|
push: |
|
tags: |
|
- 'v*' |
|
|
|
jobs: |
|
get-previous-tag: |
|
runs-on: ubuntu-latest |
|
steps: |
|
|
|
- name: Echo the git version |
|
run: echo "Git version pre dep setup is $(git --version)" |
|
|
|
- name: Install Act dependencies |
|
if: ${{ env.ACT }} |
|
run: | |
|
apt-get update |
|
apt-get install -y sudo software-properties-common curl build-essential libterm-readline-gnu-perl |
|
|
|
- name: Install additional build dependencies |
|
if: ${{ env.ACT }} |
|
run: | |
|
sudo apt-get update |
|
sudo apt-get install -y gettext libssl-dev libcurl4-openssl-dev zlib1g-dev expat libexpat1-dev |
|
|
|
- name: Download and install Git 2.44.0 |
|
run: | |
|
curl -o git-2.44.0.tar.gz https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.44.0.tar.gz |
|
tar -xzf git-2.44.0.tar.gz |
|
cd git-2.44.0 |
|
make prefix=/usr/local all |
|
sudo make prefix=/usr/local install |
|
git --version |
|
|
|
- name: Echo the git version |
|
run: echo "Git version is $(git --version)" |
|
|
|
- name: Check out code |
|
uses: actions/checkout@v4 |
|
|
|
- name: Branch |
|
run: echo "Current branch/ref is ${{ github.ref }}" |
|
|
|
- name: Get the latest tag |
|
id: get_latest_tag |
|
run: | |
|
LATEST_TAG=$(git describe --tags --abbrev=0) |
|
echo "Latest tag is $LATEST_TAG" |
|
echo "LATEST_TAG=${LATEST_TAG}" >> $GITHUB_ENV |
|
|
|
- name: Get previous tag |
|
id: get_previous_tag |
|
run: | |
|
echo "Current tags are $(git tag --sort=-v:refname)" |
|
echo "Latest tag is ${{ env.LATEST_TAG }}" |
|
ALL_TAGS=$(git tag --sort=-v:refname) |
|
PREVIOUS_TAG=$(git describe --tags --abbrev=0 $LATEST_TAG^) |
|
echo "PREVIOUS_TAG=${PREVIOUS_TAG}" >> $GITHUB_ENV |
|
|
|
- name: Output previous release tag |
|
run: echo "Previous release tag is ${{ env.PREVIOUS_TAG }} and its sha is $(git rev-parse ${{ env.PREVIOUS_TAG }})" |
|
|
|
- name: Set sha for previous release tag |
|
run: echo "PREVIOUS_TAG_SHA=$(git rev-parse ${{ env.PREVIOUS_TAG }})" >> $GITHUB_ENV |
|
|
|
- name: Output current release tag |
|
run: echo "Current release tag is ${{ env.LATEST_TAG }} and its sha is $(git rev-parse ${{ env.LATEST_TAG }})" |
|
|
|
- name: Set sha for current release tag |
|
run: echo "LATEST_TAG_SHA=$(git rev-parse ${{ env.LATEST_TAG }})" >> $GITHUB_ENV |
|
|
|
- name: Apply filters |
|
id: hasura-changes |
|
uses: dorny/paths-filter@v3 |
|
with: |
|
filters: | |
|
migrations: |
|
- 'path/to_your/migrations/**' |
|
metadata: |
|
- 'path/to_your/metadata/**' |
|
base: ${{ env.PREVIOUS_TAG_SHA }} |
|
ref: ${{ env.LATEST_TAG_SHA }} |
|
list-files: 'shell' |
|
|
|
- name: Output Hasura migration/metadata changes |
|
run: | |
|
echo "Migration changes are: ${{ steps.hasura-changes.outputs.migrations_files }}" |
|
echo "Metadata changes are: ${{ steps.hasura-changes.outputs.metadata_files }}" |
|
|
|
# Example - apply migration or metadata changes conditionally IF there are any |
|
- name: Apply Hasura migrations |
|
if: steps.hasura-changes.outputs.migrations_files != '' |
|
run: | |
|
echo "Applying Hasura migrations..." |
|
hasura migrate apply --endpoint <your-hasura-endpoint> --admin-secret <your-admin-secret> |
|
|
|
- name: Apply Hasura metadata |
|
if: steps.hasura-changes.outputs.metadata_files != '' |
|
run: | |
|
echo "Applying Hasura metadata..." |
|
hasura metadata apply --endpoint <your-hasura-endpoint> --admin-secret <your-admin-secret> |
|
|
|
|