Skip to content

Commit

Permalink
added Github Action for pack and store provider package in ghcr, and … (
Browse files Browse the repository at this point in the history
#11)

* added Github Action for pack and store provider package in ghcr, and generate magento types

* implement Makefile script to generate api types
  • Loading branch information
ca7alindev authored Jul 1, 2024
1 parent 02ff1f5 commit 476a010
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Release builds

on:
push:
tags:
- '*'

jobs:
build-and-pack:
name: Build and pack
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: CR authentication
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.ACCESS_TOKEN }}

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set VERSION env
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV

- name: Setup QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: ${{ env.DOCKER_BUILDX_VERSION }}
install: true

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}

- name: Find the Go Build Cache
id: go
run: echo "::set-output name=cache::$(make go.cachedir)"

- name: Cache the Go Build Cache
uses: actions/cache@v2
with:
path: ${{ steps.go.outputs.cache }}
key: ${{ runner.os }}-build-publish-artifacts-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-build-publish-artifacts-

- name: Cache Go Dependencies
uses: actions/cache@v2
with:
path: .work/pkg
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-

- name: Vendor Dependencies
run: make vendor vendor.check

- name: Get make submodules
run: make submodules

- name: Process swagger.json
run: make process.scheme

- name: Install crossplane CLI
id: crossplane
run: curl -sL "https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh" | sh

- name: Build provider image
run: docker build -t ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} ./cluster

- name: Build and push crossplane packages
run: ./crossplane xpkg build -f package -o provider-magento --embed-runtime-image ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} && ./crossplane xpkg push -f provider-magento ${REGISTRY}/${{ github.repository }}/provider-magento:${{ env.VERSION }} || true || true;
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,20 @@ crossplane.help:
help-special: crossplane.help

.PHONY: crossplane.help help-special

JSON_FILE := scheme.json
check_file:
@if [ ! -f $(JSON_FILE) ]; then \
echo "File $(JSON_FILE) does not exist."; \
exit 1; \
fi
# Extract path keys and process them
process.scheme: check_file
@path_keys=$$(jq -r '.paths | keys[]' $(JSON_FILE) | grep -v '{'); \
for path in $$path_keys; do \
provider_name="magento.web7.md"; \
version=$$(echo "$$path" | awk -F/ '{print tolower($$2)}'); \
type=$$(echo "$$path" | awk -F/ '{print $$NF}'); \
type=$$(echo "$$type" | awk '{print toupper(substr($$0,1,1))tolower(substr($$0,2))}'); \
$(MAKE) provider.addtype provider=$$provider_name group=$$type kind=$$type apiversion=$$version; \
done
1 change: 1 addition & 0 deletions scheme.json

Large diffs are not rendered by default.

0 comments on commit 476a010

Please sign in to comment.