Skip to content

Commit 6bf53f0

Browse files
committed
ci: update versoning pipeline and add comments for clarity
1 parent 04a6f8a commit 6bf53f0

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

.github/workflows/versioning.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Version Control
1+
name: Versioning
22
on:
33
push:
44
tags: [ 'v*.*.*' ]
@@ -8,32 +8,44 @@ jobs:
88
name: versioning
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Copy files to temporary directory
12-
shell: bash
13-
run: |
14-
cp -r content/latest tmp/content/latest
11+
# Checkout tag being pushed
12+
- name: Checkout tag
13+
uses: actions/checkout@v4
1514

1615
# This would be better if we had a current version JSON or something somewhere
1716
- name: Get prior version
17+
id: get_tag
1818
run: |
1919
PRIOR_VERSION=$(git tag -l --sort=-v:refname | head -n 1 | sed "s/v//g" | sed "s/\./-/g")
2020
echo "PRIOR_VERSION=$PRIOR_VERSION" >> $GITHUB_ENV
2121
echo "Prior version tag: $PRIOR_VERSION"
2222
23+
# Checkout main
2324
- name: Checkout main branch
2425
uses: actions/checkout@v4
2526
with:
26-
ref: main
27+
ref: ${{ steps.get_tag.outputs.PRIOR_VERSION }}
28+
path: old
2729
fetch-depth: 0
2830

31+
# Moves the old latest into it's corresponding version folder
2932
- name: Add current latest to prior version
3033
shell: bash
3134
run: |
35+
cd main
3236
mkdir "content/versions/$PRIOR_VERSION"
3337
cp -r content/latest "content/versions/$PRIOR_VERSION"
3438
39+
# Replaces latest with the new tag latest content
3540
- name: Replace latest with tagged latest
3641
shell: bash
3742
run: |
3843
rm -r content/latest/*
39-
cp -r tmp/content/latest content/latest
44+
cp -r ../content/latest content/latest
45+
46+
# Commits changes to main
47+
- name: Commit and replace
48+
run: |
49+
git add .
50+
git commit -m "Migrated ${{ github.ref_name }} into latest"
51+
git push origin main

0 commit comments

Comments
 (0)