Skip to content

Commit

Permalink
add CI to publish supergraph OCI
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed Jun 27, 2024
1 parent 86df869 commit a12a196
Showing 1 changed file with 50 additions and 10 deletions.
60 changes: 50 additions & 10 deletions .github/workflows/schema-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,47 @@ jobs:
name: supergraph.graphql
path: supergraph.graphql


publish:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs:
- generate
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
chart:
- supergraph
steps:
- name: Setup Helm
uses: azure/setup-helm@v4.0.0

- name: Install Rover CLI
run: |
curl -sSL https://rover.apollo.dev/nix/v0.23.0-rc.3 | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Download Schema Artifact
uses: actions/download-artifact@v4.1.7
with:
name: supergraph.graphql

- name: Generate Helm Chart
run: |
mkdir -p supergraph/templates
cat <<EOF > supergraph/Chart.yaml
mkdir -p ${{ matrix.chart }}/templates
cat <<EOF > ${{ matrix.chart }}/Chart.yaml
apiVersion: v2
name: supergraph
version: 0.1.0
EOF
cat <<EOF > supergraph/values.yaml
cat <<EOF > ${{ matrix.chart }}/values.yaml
EOF
cat <<EOF > supergraph/templates/supergraph-configmap.yaml
cat <<EOF > ${{ matrix.chart}}/templates/supergraph-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -49,10 +77,22 @@ jobs:
supergraph.graphql: |
EOF
sed 's/^/ /' supergraph.graphql >> supergraph/templates/supergraph-configmap.yaml
- name: testing view
run: |
ls
cat supergraph/templates/supergraph-configmap.yaml
sed 's/^/ /' supergraph.graphql >> ${{ matrix.chart }}/templates/supergraph-configmap.yaml
- name: Package Chart
run: helm package ${{ matrix.chart }}

- name: Generate Image Name
run: echo IMAGE_REPOSITORY=oci://ghcr.io/$(echo "${{ github.repository }}-${{ matrix.chart }}" | tr '[:upper:]' '[:lower:]' | tr '[_]' '[\-]') >> $GITHUB_ENV

- name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Chart
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: helm push $(ls ${{ matrix.chart }}-*.tgz) ${{ env.IMAGE_REPOSITORY }}

0 comments on commit a12a196

Please sign in to comment.