-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Somefive/feat/update-ci
Feat: update ci for build-image and helm-chart
- Loading branch information
Showing
4 changed files
with
125 additions
and
193 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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: BuildImage | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- release-* | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: { } | ||
|
||
jobs: | ||
build-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
oamdev/vela-prism | ||
ghcr.io/oam-dev/vela-prism | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=tag | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
- name: Login docker.io | ||
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0 | ||
with: | ||
registry: docker.io | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
file: ./cmd/apiserver/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: HelmChart | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
publish-charts: | ||
env: | ||
HELM_CHART: charts/ | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Get the vars | ||
id: vars | ||
run: | | ||
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} | ||
- name: Install Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.4.0 | ||
- name: Setup node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
- uses: oprypin/find-latest-tag@v1 | ||
with: | ||
repository: kubevela/workflow | ||
releases-only: true | ||
id: latest_tag | ||
- name: Tag helm chart image | ||
run: | | ||
latest_repo_tag=${{ steps.latest_tag.outputs.tag }} | ||
sub="." | ||
major="$(cut -d"$sub" -f1 <<<"$latest_repo_tag")" | ||
minor="$(cut -d"$sub" -f2 <<<"$latest_repo_tag")" | ||
patch="0" | ||
current_repo_tag="$major.$minor.$patch" | ||
image_tag=${GITHUB_REF#refs/tags/} | ||
chart_version=$latest_repo_tag | ||
if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then | ||
image_tag=latest | ||
chart_version=${current_repo_tag}-nightly-build | ||
fi | ||
sed -i "s/latest/${image_tag}/g" $HELM_CHART/values.yaml | ||
chart_smever=${chart_version#"v"} | ||
sed -i "s/0.1.0/$chart_smever/g" $HELM_CHART/Chart.yaml | ||
- uses: jnwng/github-app-installation-token-action@v2 | ||
id: get_app_token | ||
with: | ||
appId: 340472 | ||
installationId: 38064967 | ||
privateKey: ${{ secrets.GH_KUBEVELA_APP_PRIVATE_KEY }} | ||
- name: Sync Chart Repo | ||
run: | | ||
git config --global user.email "135009839+kubevela[bot]@users.noreply.github.com" | ||
git config --global user.name "kubevela[bot]" | ||
git clone https://x-access-token:${{ steps.get_app_token.outputs.token }}@github.com/kubevela/charts.git kubevela-charts | ||
helm package $HELM_CHART --destination ./kubevela-charts/docs/ | ||
helm repo index --url https://kubevela.github.io/charts ./kubevela-charts/docs/ | ||
cd kubevela-charts/ | ||
git add docs/ | ||
chart_version=${GITHUB_REF#refs/tags/} | ||
git commit -m "update vela-prism chart ${chart_version}" | ||
git push https://x-access-token:${{ steps.get_app_token.outputs.token }}@github.com/kubevela/charts.git |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.