add: mainにpush時のactions #16
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
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-console-client: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./console/client | |
tags: ${{ vars.DOCKER_ACCOUNT_NAME }}/bealink-console-client:${{ github.sha }} | |
push: true | |
build-console-server: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./console/server | |
tags: ${{ vars.DOCKER_ACCOUNT_NAME }}/bealink-console-server:${{ github.sha }} | |
push: true | |
build-linker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./linker | |
tags: ${{ vars.DOCKER_ACCOUNT_NAME }}/bealink-linker:${{ github.sha }} | |
modify-k8s-yaml: | |
needs: | |
- build-console-client | |
- build-console-server | |
- build-linker | |
runs-on: ubuntu-latest | |
steps: | |
- name: auth-as-github-app | |
id: auth_as_github_app | |
uses: tibdex/github-app-token@v1 | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.PRIVATE_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
repository: 'bearsan/k8s-cluster-yaml' | |
token: ${{ steps.auth_as_github_app.outputs.token }} | |
- name: create branch | |
run: | | |
git config --global user.name "Actions User" | |
git config --global user.email "[email protected]" | |
git checkout -b update-bealink-to-${{ github.sha }} main | |
git push -u origin update-bealink-to-${{ github.sha }} | |
- name: chage docker image | |
uses: mikefarah/yq@master | |
env: | |
TAG: ${{ github.sha }} | |
with: | |
cmd: yq eval '.spec.sources[2].helm.valuesObject.targetRevision = ${TAG}' -i argocd/bealink.yaml | |
- name: commit and push | |
run: | | |
git add -A | |
git commit -m "Update docker image tag onto ${TAG}" | |
git push origin update-bealink-to-${{ github.sha }} | |
gh pr create --title "Update docker image tag onto ${TAG}" --body "Update docker image tag onto ${TAG}" --base main --head update-bealink-to-${{ github.sha }} -r ${{ vars.INFRA_REVIEWER }} | |
env: | |
GITHUB_TOKEN: ${{ steps.auth_as_github_app.outputs.token }} |