Compare commits
32 Commits
b400a63696
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3fb26a8a2
|
||
|
|
a247bed8d4
|
||
|
|
cac5e8ff15
|
||
|
|
9a49e2c994
|
||
|
|
9f0fcb1b7e
|
||
|
|
3fa4045772
|
||
|
|
82e109b10b
|
||
|
|
b0ce0a956b
|
||
|
|
1ccb70138e
|
||
|
|
f9d823535e
|
||
|
|
f57b277951
|
||
|
|
ae9a2e17c1
|
||
|
|
d6a1e650dc
|
||
|
|
e96743093f
|
||
|
|
e4236cff6b
|
||
|
|
afe07ae420
|
||
|
|
123c750a59
|
||
|
|
056c391fe7
|
||
|
|
eebe74744b
|
||
|
|
eaf474d9eb
|
||
|
|
1d136f7000
|
||
|
|
26fee97c1c
|
||
|
|
ba142c4a56
|
||
|
|
7f46b0cd62
|
||
|
|
06ab24d428
|
||
|
|
3827fa7394
|
||
|
|
6d99c082d3
|
||
|
|
63e124a3a3
|
||
|
|
f942374041
|
||
|
|
7629fca727 | ||
|
|
31f2c913d7 | ||
|
|
4378172d31
|
@@ -1,28 +1,32 @@
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
env:
|
||||||
|
NAMESPACE: ${{ github.repository_owner }}
|
||||||
|
DOCKER_REGISTRY: ghcr.io
|
||||||
|
DOCKER_REPOSITORY: ${{ github.repository }}
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
|
env:
|
||||||
|
IMAGE: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REPOSITORY }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: benjlevesque/short-sha@v3.0
|
- name: Install kpack-cli
|
||||||
id: short-sha
|
|
||||||
with:
|
|
||||||
length: 10
|
|
||||||
- name: Set up kpack-cli
|
|
||||||
env:
|
env:
|
||||||
KPACK_CLI_VERSION: "0.13.0"
|
KPACK_CLI_VERSION: 0.13.0
|
||||||
|
KPACK_CLI_SHA256: 52f0c927a1350f4f1bb281575ec246f406fb96aa69dc974ed10a2fe52c538158
|
||||||
working-directory: /tmp
|
working-directory: /tmp
|
||||||
run: |
|
run: |
|
||||||
mkdir kp-binaries
|
set -ex
|
||||||
curl -L "https://github.com/buildpacks-community/kpack-cli/releases/download/v${KPACK_CLI_VERSION}/kp-linux-amd64-${KPACK_CLI_VERSION}" -o kp-binaries/kp-linux-amd64-${KPACK_CLI_VERSION}
|
curl -sLO "https://github.com/buildpacks-community/kpack-cli/releases/download/v${KPACK_CLI_VERSION}/kp-linux-amd64-${KPACK_CLI_VERSION}"
|
||||||
curl -LO "https://github.com/buildpacks-community/kpack-cli/releases/download/v${KPACK_CLI_VERSION}/kp-linux-amd64-${KPACK_CLI_VERSION}.sha256"
|
echo "${KPACK_CLI_SHA256} kp-linux-amd64-${KPACK_CLI_VERSION}" | sha256sum --check || exit 1
|
||||||
sha256sum -c kp-linux-amd64-${KPACK_CLI_VERSION}.sha256 || exit 1
|
sudo mv kp-linux-amd64-${KPACK_CLI_VERSION} /usr/local/bin/kp
|
||||||
sudo mv kp-binaries/kp-linux-amd64-${KPACK_CLI_VERSION} /usr/local/bin/kp
|
|
||||||
sudo chmod +x /usr/local/bin/kp
|
sudo chmod +x /usr/local/bin/kp
|
||||||
kp version
|
kp version
|
||||||
- name: Set up kubectl
|
- name: Install kubectl
|
||||||
uses: azure/setup-kubectl@v4
|
uses: azure/setup-kubectl@v4
|
||||||
- name: Configure kubectl
|
- name: Configure kubectl
|
||||||
uses: azure/k8s-set-context@v1
|
uses: azure/k8s-set-context@v1
|
||||||
@@ -31,16 +35,20 @@ jobs:
|
|||||||
- name: Update kpack image
|
- name: Update kpack image
|
||||||
env:
|
env:
|
||||||
SHA: ${{ github.sha }}
|
SHA: ${{ github.sha }}
|
||||||
SHORT_SHA: ${{ steps.short-sha.outputs.sha }}
|
|
||||||
run: |
|
run: |
|
||||||
kp image patch tutorial-image --replace-additional-tag "ghcr.io/hvg-dev/php-test:sha-${SHORT_SHA}" --git-revision "${SHA}" -n test-builder
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
||||||
|
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV
|
||||||
|
IMAGE_NAME="${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}-${GITHUB_REF##*/}"
|
||||||
|
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
|
||||||
|
kp image patch $IMAGE_NAME --replace-additional-tag "${IMAGE}:sha-${SHORT_SHA}" --git-revision "${SHA}" -n $NAMESPACE
|
||||||
|
kp image status $IMAGE_NAME -n $NAMESPACE
|
||||||
- name: Wait for build to complete
|
- name: Wait for build to complete
|
||||||
run: |
|
run: |
|
||||||
BUILD=$(kubectl -n test-builder get image tutorial-image -o jsonpath='{.status.buildCounter}')
|
BUILD=$(kubectl -n $NAMESPACE get image $IMAGE_NAME -o jsonpath='{.status.buildCounter}')
|
||||||
BUILD_REF=$(kubectl -n test-builder get image tutorial-image -o jsonpath='{.status.latestBuildRef}')
|
BUILD_REF=$(kubectl -n $NAMESPACE get image $IMAGE_NAME -o jsonpath='{.status.latestBuildRef}')
|
||||||
kp build logs tutorial-image -n test-builder --build ${BUILD}
|
kp build logs $IMAGE_NAME -n $NAMESPACE --build ${BUILD}
|
||||||
kp build status tutorial-image -n test-builder -b $BUILD
|
kp build status $IMAGE_NAME -n $NAMESPACE -b $BUILD
|
||||||
if [ "$(kubectl -n test-builder get build $BUILD_REF -o jsonpath='{.status.conditions[0].status}')" != "True" ]; then exit 1; fi
|
if [ "$(kubectl -n $NAMESPACE get build $BUILD_REF -o jsonpath='{.status.conditions[0].status}')" != "True" ]; then exit 1; fi
|
||||||
# - name: Update Kubernetes deployment
|
# - name: Update Kubernetes deployment
|
||||||
# run: |
|
# run: |
|
||||||
# kubectl set image deployment/my-app my-app=<registry>/<repository>:${{ github.sha }}
|
# kubectl set image deployment/my-app my-app=<registry>/<repository>:${{ github.sha }}
|
||||||
|
|||||||
17
.github/workflows/cicd.yaml
vendored
17
.github/workflows/cicd.yaml
vendored
@@ -1,15 +1,22 @@
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
jobs:
|
jobs:
|
||||||
build-image-and-deploy:
|
build-image-and-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: yesolutions/mirror-action@master
|
|
||||||
|
- uses: felegy/mirror-action@master
|
||||||
with:
|
with:
|
||||||
REMOTE: https://git.saito.systems/felegy/test-php.git
|
REMOTE: git@${{ secrets.DEPLOY_REPO }}:${{ github.repository }}.git
|
||||||
GIT_USERNAME: felegy
|
SSH_CONFIG: |
|
||||||
GIT_PASSWORD: ${{ secrets.DEPLOY_REPO_TOKEN }}
|
Host ${{ secrets.DEPLOY_REPO }}
|
||||||
|
ProxyCommand cloudflared access ssh --hostname %h
|
||||||
|
GIT_SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
GIT_SSH_NO_VERIFY_HOST: "true"
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: runner-role
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["*"]
|
||||||
|
resources: ["*"]
|
||||||
|
verbs: ["*"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: runner-role-binding
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: default
|
||||||
|
roleRef:
|
||||||
|
kind: Role
|
||||||
|
name: runner-role
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
---
|
||||||
kind: PersistentVolumeClaim
|
kind: PersistentVolumeClaim
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
metadata:
|
metadata:
|
||||||
|
|||||||
Reference in New Issue
Block a user