Skip to content

Merge pull request #14 from dyllamt/feature/try-pipeline-again #10

Merge pull request #14 from dyllamt/feature/try-pipeline-again

Merge pull request #14 from dyllamt/feature/try-pipeline-again #10

name: Release Artifacts
on:
push:
branches:
- main
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Extract version from file
id: extract_version
run: echo "::set-output name=version::$(cat VERSION)"
new-version-check:
needs: get-version
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check_image.outputs.should_release }}
steps:
- name: Check if Docker image exists with current version
id: check_image
run: |
VERSION=${{ needs.get-version.outputs.version }}
IMAGE_NAME="ghcr.io/dyllamt/coinbase-connector:$VERSION"
if curl -f -sL $IMAGE_NAME > /dev/null; then
echo "Docker image with version $VERSION exists."
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "Docker image with version $VERSION does not exist."
echo "should_release=true" >> $GITHUB_OUTPUT
fi
docker-push:
needs: [get-version, new-version-check]
if: needs.new-version-check.outputs.should_release == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ghcr.io/dyllamt/coinbase-connector:${{ needs.get-version.outputs.version }},ghcr.io/dyllamt/coinbase-connector:latest
helm-release:
needs: [get-version, new-version-check]
if: needs.new-version-check.outputs.should_release == true
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Update Chart Versions
run: |
VERSION=${{ needs.prepare.outputs.version }}
CHARTS_DIR=charts
for CHART in $CHARTS_DIR/*; do
if [ -d "$CHART" ]; then
CHART_PATH="$CHART/Chart.yaml"
if [ -f "$CHART_PATH" ]; then
echo "Updating version in $CHART_PATH to $VERSION"
sed -i "s/version: .*/version: $VERSION/" $CHART_PATH
else
echo "No Chart.yaml found in $CHART"
fi
fi
done
- name: Release Helm Charts
uses: helm/chart-releaser-action@v1.6.0
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
helm-docs:
needs: get-version
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: 'main'
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '^1.17'
- name: Generate Documentation
run: |
go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
cd charts
for d in */ ; do
helm-docs -c $d
done
- name: Checkout gh-pages Branch
uses: actions/checkout@v3
with:
ref: 'gh-pages'
path: 'gh-pages'
- name: Copy Documentation to gh-pages
run: |
for CHART_DIR in charts/*; do
if [ -d "$CHART_DIR" ]; then # Ensure it's a directory
CHART_NAME=$(basename $CHART_DIR)
# Create a matching directory structure in gh-pages
mkdir -p gh-pages/$CHART_NAME
# Copy the README.md for the chart
cp $CHART_DIR/README.md gh-pages/$CHART_NAME/
fi
done
- name: Commit and Push Changes to gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd gh-pages
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add .
git commit -m "Update documentation" -a || echo "No changes to commit"
git push origin gh-pages