Skip to content

Commit

Permalink
Merge pull request #11 from magda-io/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
t83714 authored Oct 31, 2022
2 parents 625b568 + adba892 commit 82637df
Show file tree
Hide file tree
Showing 20 changed files with 632 additions and 750 deletions.
47 changes: 37 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,49 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Login to GitHub Container Registry
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: yarn install
- run: yarn build
- run: yarn test

- name: helm-build-dependencies
run: yarn update-all-charts

- run: yarn update-all-charts
- run: yarn helm-lint

- name: Login to GitHub Package Repository
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
run: docker login docker.pkg.github.com -u magdabot -p ${GH_TOKEN}
- name: Check Helm Chart Document
run: |
code=0
docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:v1.5.0 -t ./README.md.gotmpl -o ../../README.md || code=$?;
if [ "$code" != "0" ]; then
echo "Failed to run helm-docs!";
exit 1;
fi;
cd deploy
code=0
git ls-files -m | grep -i readme.md || code=$?;
if [ "$code" == "0" ]; then
echo -e "Some of helm chart docs are required to be updated using the [helm-docs](https://github.com/norwoodj/helm-docs) tool. \n
Please run helm-docs (v1.5.0) at project root, review & commit docs changes and push a new commit.";
exit 1;
else
echo -e "helm docs check passed. helm docs update is not required.";
fi;
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build Docker Image & Push
run: yarn docker-build-prod --repository=docker.pkg.github.com/magda-io/${REPO_NAME} --name=${REPO_NAME} --version=${GITHUB_SHA}
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
yarn docker-build-prod --repository=ghcr.io/${REPO_OWNER} --name=${REPO_NAME} --version=${GITHUB_SHA} --platform=linux/amd64,linux/arm64
93 changes: 49 additions & 44 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ on:
types: [published]

env:
# [avoid issue when Github action upgraded from 18.04 default to 20.04](https://github.com/aws/aws-cli/issues/5262)
AWS_EC2_METADATA_DISABLED: true
REPO_NAME: magda-minion-broken-link
# Github account username (used for access github registry)
GH_USERNAME: magdabot
# Github Orgnisation name or user name for this repo
GH_ORGNAME: magda-io
#Docker Hub username
DH_USERNAME: magdabot
#S3 bucket name: this s3 bucket will be used to store published helm chart and index
S3_BUCKET: magda-charts

jobs:
release-helm-chart:
Expand All @@ -24,56 +14,71 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Use Node.js 10
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 10
node-version: 14

- name: Login to GitHub Container Registry
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: yarn install
- run: yarn build
- run: yarn test

- name: helm-build-dependencies
run: yarn update-all-charts
- run: yarn update-all-charts
- run: yarn helm-lint

- name: helm-check
run: yarn helm-lint
- name: Check Helm Chart Document
run: |
code=0
docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:v1.5.0 -t ./README.md.gotmpl -o ../../README.md || code=$?;
if [ "$code" != "0" ]; then
echo "Failed to run helm-docs!";
exit 1;
fi;
cd deploy
code=0
git ls-files -m | grep -i readme.md || code=$?;
if [ "$code" == "0" ]; then
echo -e "Some of helm chart docs are required to be updated using the [helm-docs](https://github.com/norwoodj/helm-docs) tool. \n
Please run helm-docs (v1.5.0) at project root, review & commit docs changes and push a new commit.";
exit 1;
else
echo -e "helm docs check passed. helm docs update is not required.";
fi;
- name: helm-chart-version-check
run: yarn check-helm-chart-version deploy/${REPO_NAME}/Chart.yaml

- name: Login to GitHub Package Repository
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
run: docker login docker.pkg.github.com -u ${GH_USERNAME} -p ${GH_TOKEN}

- name: Build Docker Image & Push to Github Registry
run: yarn docker-build-prod --repository=docker.pkg.github.com/${GH_ORGNAME}/${REPO_NAME} --name=${REPO_NAME}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Login to Docker Hub
env:
DH_TOKEN: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: docker login -u ${DH_USERNAME} -p ${DH_TOKEN}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Re-tag & Push Docker Image to Docker Hub
run: yarn retag-and-push --fromPrefix=docker.pkg.github.com/${GH_ORGNAME}/${REPO_NAME}/ --fromName=${REPO_NAME}
- name: Build Docker Image & Push
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
yarn docker-build-prod --repository=ghcr.io/${REPO_OWNER} --name=${REPO_NAME} --version=${GITHUB_SHA} --platform=linux/amd64,linux/arm64
- name: Configure Git
- name: Re-tag & Push Docker Images
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
PACKAGE_JSON_VERSION=$(jq -r ".version" ./package.json)
chmod +r $HOME/.docker/config.json
# Re-push to ghcr.io
docker container run --rm --net host \
-v regctl-conf:/home/appuser/.regctl/ \
-v $HOME/.docker/config.json:/home/appuser/.docker/config.json \
regclient/regctl:v0.3.9 image copy ghcr.io/${REPO_OWNER}/${REPO_NAME}:${GITHUB_SHA} ghcr.io/${REPO_OWNER}/${REPO_NAME}:${PACKAGE_JSON_VERSION}
- name: Release Helm Chart
env:
CR_TOKEN: "${{ secrets.GH_ACCESS_TOKEN }}"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
cd deploy
mkdir -p sync_dir
mkdir -p index_dir
if ! aws s3 cp s3://${S3_BUCKET}/index.yaml index_dir/index.yaml; then echo "failed to copy current repo index" && exit 1; fi
helm package -d sync_dir ${REPO_NAME}
helm repo index --merge "index_dir/index.yaml" sync_dir
mv -f sync_dir/index.yaml index_dir/index.yaml
aws s3 sync sync_dir s3://${S3_BUCKET}/
aws s3 cp index_dir/index.yaml s3://${S3_BUCKET}/index.yaml
helm package ${REPO_NAME}
PKG_NAME=`ls *.tgz`
helm push ${PKG_NAME} oci://ghcr.io/${REPO_OWNER}/charts
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extension": ["ts"],
"spec": "src/test/**/*.spec.ts",
"require": "ts-node/register"
}
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.0.0

- Upgrade nodejs to version 14
- Upgrade other dependencies
- Release all artifacts to GitHub Container Registry (instead of docker.io & https://charts.magda.io)
- Upgrade magda-common chart version
- Upgrade api to batch/v1 to be compatible with k8s 1.25 (now requires >=1.21)

# 1.0.0

- Upgrade dependencies
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:12-alpine
FROM node:14-alpine

RUN mkdir -p /usr/src/app
COPY . /usr/src/app
WORKDIR /usr/src/app/component
ENTRYPOINT [ "node", "/usr/src/app/component/dist/index.js" ]
ENTRYPOINT [ "node", "/usr/src/app/component/dist/index.js" ]
35 changes: 13 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,26 @@ Other aspects exist that are written to by many minions - for instance, we have

This magda minion will test if a distribution is still available and record the link status accordingly.

### Helm Chart
### Release Registry

It's recommanded to deploy minions with as [dependencies](https://helm.sh/docs/topics/chart_best_practices/dependencies/) of a Magda helm deployment. Example can be found from [here](https://github.com/magda-io/magda-config).
Since v2.0.0, we use [Github Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) as our official Helm Chart & Docker Image release registry.

- Magda Helm Charts Repository Url: https://charts.magda.io
It's recommended to deploy minions with as [dependencies](https://helm.sh/docs/topics/chart_best_practices/dependencies/) of a Magda helm deployment.

The [helm chart](https://helm.sh/docs/topics/charts/) for this minion is auto released when a [Github Release](https://help.github.com/en/github/administering-a-repository/creating-releases) is created for this repo.

- Add repository to helm:

```bash
helm repo add magda-io https://charts.magda.io
```yaml
dependencies:
- name: magda-minion-broken-link
version: "2.0.0"
repository: "oci://ghcr.io/magda-io/charts"
```
### Docker Image

Docker image releases can be found from Docker Hub:

https://hub.docker.com/r/data61/magda-minion-broken-link/

Development releases (per commit) are also available from [GitHub Registry](https://github.com/magda-io/magda-minion-broken-link/packages) and accessible with access token.

## Requirements
Kubernetes: `>= 1.14.0-0`
Kubernetes: `>= 1.21.0`

| Repository | Name | Version |
| ----------------------- | ------------ | ------------- |
| https://charts.magda.io | magda-common | 1.0.0-alpha.4 |
| Repository | Name | Version |
| ----------------------------- | ------------ | ------- |
| oci://ghcr.io/magda-io/charts | magda-common | 2.1.1 |

## Values

Expand All @@ -50,7 +41,7 @@ Kubernetes: `>= 1.14.0-0`
| defaultAdminUserId | string | `"00000000-0000-4000-8000-000000000000"` | |
| defaultImage.imagePullSecret | bool | `false` | |
| defaultImage.pullPolicy | string | `"IfNotPresent"` | |
| defaultImage.repository | string | `"docker.io/data61"` | |
| defaultImage.repository | string | `"ghcr.io/magda-io"` | |
| global.image | object | `{}` | |
| global.minions.image | object | `{}` | |
| global.rollingUpdate | object | `{}` | |
Expand Down
25 changes: 8 additions & 17 deletions README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,19 @@ Other aspects exist that are written to by many minions - for instance, we have

This magda minion will test if a distribution is still available and record the link status accordingly.

### Helm Chart
### Release Registry

It's recommanded to deploy minions with as [dependencies](https://helm.sh/docs/topics/chart_best_practices/dependencies/) of a Magda helm deployment. Example can be found from [here](https://github.com/magda-io/magda-config).
Since v2.0.0, we use [Github Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) as our official Helm Chart & Docker Image release registry.

- Magda Helm Charts Repository Url: https://charts.magda.io
It's recommended to deploy minions with as [dependencies](https://helm.sh/docs/topics/chart_best_practices/dependencies/) of a Magda helm deployment.

The [helm chart](https://helm.sh/docs/topics/charts/) for this minion is auto released when a [Github Release](https://help.github.com/en/github/administering-a-repository/creating-releases) is created for this repo.

- Add repository to helm:

```bash
helm repo add magda-io https://charts.magda.io
```yaml
dependencies:
- name: magda-minion-broken-link
version: "2.0.0"
repository: "oci://ghcr.io/magda-io/charts"
```

### Docker Image

Docker image releases can be found from Docker Hub:

https://hub.docker.com/r/data61/magda-minion-broken-link/

Development releases (per commit) are also available from [GitHub Registry](https://github.com/magda-io/magda-minion-broken-link/packages) and accessible with access token.

{{ template "chart.maintainersSection" . }}

{{ template "chart.requirementsSection" . }}
Expand Down
8 changes: 4 additions & 4 deletions deploy/magda-minion-broken-link/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: magda-common
repository: https://charts.magda.io
version: 1.0.0-alpha.4
digest: sha256:a5dcf2df16ca5a3972f92d91434c2e78be0ce411994d2a3cb89c674a711ddc24
generated: "2021-10-12T20:12:30.701077+11:00"
repository: oci://ghcr.io/magda-io/charts
version: 2.1.1
digest: sha256:ec6c98cd98ef7a74e919a4b87b8700658c4d4b66a063f2462a237234ebd00e10
generated: "2022-10-14T17:24:41.750803+11:00"
8 changes: 4 additions & 4 deletions deploy/magda-minion-broken-link/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v2
name: magda-minion-broken-link
description: A Helm chart for Magda Broken Link Minion
version: "1.0.0"
kubeVersion: ">= 1.14.0-0"
version: "2.0.0"
kubeVersion: ">= 1.21.0"
home: "https://github.com/magda-io/magda-minion-broken-link"
sources: [ "https://github.com/magda-io/magda-minion-broken-link" ]
annotations:
magdaModuleType: "minion"
dependencies:
- name: magda-common
version: "1.0.0-alpha.4"
repository: "https://charts.magda.io"
version: "2.1.1"
repository: "oci://ghcr.io/magda-io/charts"
2 changes: 1 addition & 1 deletion deploy/magda-minion-broken-link/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: minion-broken-link-recrawl
Expand Down
2 changes: 1 addition & 1 deletion deploy/magda-minion-broken-link/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cronJobImage:
pullSecrets: false

defaultImage:
repository: docker.io/data61
repository: ghcr.io/magda-io
pullPolicy: IfNotPresent
imagePullSecret: false

Expand Down
Loading

0 comments on commit 82637df

Please sign in to comment.