|
1 | | -name: Docker Build |
2 | | - |
| 1 | +name: Build and Deploy |
3 | 2 | on: |
4 | 3 | push: |
5 | 4 | branches: |
6 | | - - "dev" |
7 | | - - "main" |
8 | | - |
9 | | -env: |
10 | | - IMAGE_NAME: rss3/xchar |
11 | | - REGION_ID: us-east-1 |
12 | | - DEV_ACK_CLUSTER_ID: cd1d0ffc40b5242b39ddda1864e71e30d |
13 | | - PROD_ACK_CLUSTER_ID: cfc647c22fd6848b5a602ad4d7470632b |
14 | | - |
| 5 | + - dev |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - v* |
15 | 9 | jobs: |
16 | 10 | build: |
17 | | - runs-on: ubuntu-latest |
18 | | - outputs: |
19 | | - version: ${{ steps.meta.outputs.version }} |
20 | | - steps: |
21 | | - - name: Checkout |
22 | | - uses: actions/checkout@v3 |
23 | | - - name: docker meta |
24 | | - id: meta |
25 | | - uses: docker/metadata-action@v4 |
26 | | - with: |
27 | | - images: ${{ env.IMAGE_NAME }} |
28 | | - tags: | |
29 | | - type=sha |
30 | | - - name: Set up Docker Buildx |
31 | | - uses: docker/setup-buildx-action@v2 |
32 | | - - name: Login to DockerHub |
33 | | - if: github.event_name != 'pull_request' |
34 | | - uses: docker/login-action@v2 |
35 | | - with: |
36 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
37 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
38 | | - - name: Build and push |
39 | | - uses: docker/build-push-action@v3 |
40 | | - with: |
41 | | - context: . |
42 | | - file: Dockerfile |
43 | | - push: ${{ github.event_name != 'pull_request' }} |
44 | | - tags: ${{ steps.meta.outputs.tags }} |
45 | | - labels: ${{ steps.meta.outputs.labels }} |
46 | | - |
| 11 | + uses: NaturalSelectionLabs/Daedalus/.github/workflows/docker-tpl.yaml@main |
| 12 | + with: |
| 13 | + images: flosspicks/xchar |
| 14 | + context: . |
| 15 | + dockerfile: ./Dockerfile |
| 16 | + secrets: |
| 17 | + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 18 | + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} |
47 | 19 | deploy-dev: |
48 | | - runs-on: ubuntu-latest |
49 | | - needs: [build] |
50 | | - steps: |
51 | | - - name: Checkout |
52 | | - uses: actions/checkout@v3 |
53 | | - - name: Set K8s context |
54 | | - uses: aliyun/ack-set-context@v1 |
55 | | - with: |
56 | | - access-key-id: "${{ secrets.ACCESS_KEY_ID }}" |
57 | | - access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}" |
58 | | - cluster-id: "${{ env.DEV_ACK_CLUSTER_ID }}" |
59 | | - - name: Install Tools |
60 | | - run: | |
61 | | - wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64.tar.gz -O - | tar xz && mv yq_linux_amd64 /usr/local/bin/yq |
62 | | - curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.22.10/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/kubectl |
63 | | - - uses: sljeff/secrets2env@main |
64 | | - with: |
65 | | - secrets-json: ${{ toJson(secrets) }} |
66 | | - - env: |
67 | | - IMAGE_TAG_RELEASE: ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.version }} |
68 | | - run: | |
69 | | - sh apply.sh deploy/dev/* |
70 | | -
|
| 20 | + if: github.ref == 'refs/heads/dev' |
| 21 | + uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main |
| 22 | + needs: |
| 23 | + - build |
| 24 | + with: |
| 25 | + images: flosspicks/xchar |
| 26 | + tag: sha-${{ github.sha }} |
| 27 | + cluster: dev |
| 28 | + namespace: crossbell |
| 29 | + releaseName: xchar |
| 30 | + revision: develop |
| 31 | + dir: deploy/dev |
| 32 | + secrets: |
| 33 | + GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} |
71 | 34 | deploy-prod: |
72 | 35 | if: github.ref == 'refs/heads/main' |
73 | | - runs-on: ubuntu-latest |
74 | | - needs: [build, deploy-dev] |
75 | | - steps: |
76 | | - - name: Checkout |
77 | | - uses: actions/checkout@v3 |
78 | | - - name: Set K8s context |
79 | | - uses: aliyun/ack-set-context@v1 |
80 | | - with: |
81 | | - access-key-id: "${{ secrets.ACCESS_KEY_ID }}" |
82 | | - access-key-secret: "${{ secrets.ACCESS_KEY_SECRET }}" |
83 | | - cluster-id: "${{ env.PROD_ACK_CLUSTER_ID }}" |
84 | | - - name: Install Tools |
85 | | - run: | |
86 | | - wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_amd64.tar.gz -O - | tar xz && mv yq_linux_amd64 /usr/local/bin/yq |
87 | | - curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.22.10/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/kubectl |
88 | | - - uses: sljeff/secrets2env@main |
89 | | - with: |
90 | | - secrets-json: ${{ toJson(secrets) }} |
91 | | - - env: |
92 | | - IMAGE_TAG_RELEASE: ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.version }} |
93 | | - run: | |
94 | | - sh apply.sh deploy/prod/* |
| 36 | + uses: NaturalSelectionLabs/Daedalus/.github/workflows/deploy-v3-tpl.yaml@main |
| 37 | + needs: |
| 38 | + - build |
| 39 | + with: |
| 40 | + images: flosspicks/xchar |
| 41 | + tag: sha-${{ github.sha }} |
| 42 | + cluster: prod |
| 43 | + namespace: crossbell |
| 44 | + releaseName: xchar |
| 45 | + revision: main |
| 46 | + dir: deploy/prod |
| 47 | + secrets: |
| 48 | + GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} |
0 commit comments