-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f55065e
commit 5656896
Showing
1 changed file
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
slug: ${{ steps.information.outputs.slug }} | ||
target: ${{ steps.information.outputs.target }} | ||
version: ${{ steps.read_version.outputs.version }} | ||
version_changed: ${{ steps.check_version.outputs.version_changed }} | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/checkout@v4 | ||
|
@@ -64,16 +65,19 @@ | |
run: | | ||
VERSION=$(cat ./${{ matrix.folder }}/version.txt) | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
- name: Fetch version from main branch | ||
id: fetch_main_version | ||
- name: Read previous version from previous_version.txt | ||
id: read_previous_version | ||
run: | | ||
git fetch origin main | ||
MAIN_VERSION=$(git show origin/main:${{ matrix.folder }}/version.txt || echo "") | ||
echo "main_version=$MAIN_VERSION" >> $GITHUB_OUTPUT | ||
if [ -f ./${{ matrix.folder }}/previous_version.txt ]; then | ||
PREVIOUS_VERSION=$(cat ./${{ matrix.folder }}/previous_version.txt) | ||
else | ||
PREVIOUS_VERSION="" | ||
fi | ||
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT | ||
- name: Check if version has changed | ||
id: check_version | ||
run: | | ||
if [ "${{ steps.read_version.outputs.version }}" = "${{ steps.fetch_main_version.outputs.main_version }}" ]; then | ||
if [ "${{ steps.read_version.outputs.version }}" = "${{ steps.read_previous_version.outputs.previous_version }}" ]; then | ||
echo "version_changed=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "version_changed=true" >> $GITHUB_OUTPUT | ||
|
@@ -92,20 +96,21 @@ | |
run: | | ||
VERSION=$(cat ./${{ matrix.folder }}/version.txt) | ||
jq --arg version "$VERSION" '.args.BUILD_VERSION = $version' ./${{ matrix.folder }}/build.json > tmp.json && mv tmp.json ./${{ matrix.folder }}/build.json | ||
- name: Update previous_version.txt if version has changed | ||
if: steps.check_version.outputs.version_changed == 'true' | ||
run: | | ||
echo "${{ steps.read_version.outputs.version }}" > ./${{ matrix.folder }}/previous_version.txt | ||
- name: Commit and push changes | ||
if: steps.check_version.outputs.version_changed == 'true' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
git add ./${{ matrix.folder }}/config.json ./${{ matrix.folder }}/build.json | ||
if ! git diff-index --quiet HEAD; then | ||
git commit -m "Update version in config.json and build.json" | ||
git pull --rebase origin ${{ github.ref }} | ||
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }} | ||
else | ||
echo "No changes to commit" | ||
fi | ||
git add ./${{ matrix.folder }}/config.json ./${{ matrix.folder }}/build.json ./${{ matrix.folder }}/previous_version.txt | ||
git commit -m "Update version and previous_version.txt" | ||
git pull origin ${{ github.ref }} | ||
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }} | ||
- name: Debug - List extracted information | ||
run: | | ||
echo "Architectures: ${{ steps.information.outputs.architectures }}" | ||
|
@@ -115,6 +120,7 @@ | |
echo "Slug: ${{ steps.information.outputs.slug }}" | ||
echo "Target: ${{ steps.information.outputs.target }}" | ||
echo "Version: ${{ steps.read_version.outputs.version }}" | ||
echo "Previous Version: ${{ steps.read_previous_version.outputs.previous_version }}" | ||
echo "Version changed: ${{ steps.check_version.outputs.version_changed }}" | ||
lint-hadolint: | ||
|
@@ -226,7 +232,7 @@ | |
git add ./${{ matrix.folder }}/config.json ./${{ matrix.folder }}/build.json | ||
if ! git diff-index --quiet HEAD; then | ||
git commit -m "Prettified Code!" | ||
git pull --rebase origin ${{ github.ref }} | ||
git pull origin ${{ github.ref }} | ||
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }} | ||
else | ||
echo "No changes to commit" | ||
|
@@ -473,7 +479,6 @@ | |
name: Create and Push Docker Manifest | ||
runs-on: ubuntu-latest | ||
needs: build_main_or_pr | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/checkout@v4 | ||
|
@@ -516,7 +521,6 @@ | |
name: Create and Push Docker Manifest | ||
runs-on: ubuntu-latest | ||
needs: build_other_branches | ||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
steps: | ||
- name: Check out code from GitHub | ||
uses: actions/checkout@v4 | ||
|