Skip to content

Commit 8a918bd

Browse files
committed
🏗 Correction on build.yaml
1 parent a3b41ef commit 8a918bd

File tree

1 file changed

+32
-13
lines changed

1 file changed

+32
-13
lines changed

.github/workflows/build.yaml

+32-13
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
build-musl:
1515
runs-on: ubuntu-latest
1616
# So we need to put the condition in the if here
17-
if: ${{ (github.actor == github.event.repository.owner.login) && (github.ref == 'refs/heads/master') }}
17+
if: ${{ (github.actor == github.event.repository.owner.login) && (github.ref == 'refs/heads/main') }}
1818

1919
steps:
2020
- name: Run sccache-cache
@@ -40,7 +40,7 @@ jobs:
4040
with:
4141
registry: ghcr.io
4242
username: ${{ github.actor }}
43-
password: ${{ secrets.GITHUB_TOKEN }}
43+
password: ${{ secrets.REGISTRY_TOKEN }}
4444

4545

4646
- name: Build and push
@@ -53,20 +53,39 @@ jobs:
5353
ghcr.io/guilamb/interspecies-reviewer:latest
5454
ghcr.io/guilamb/interspecies-reviewer:${{ github.run_number }}
5555
secrets: |
56-
"github_token=${{ secrets.GITHUB_TOKEN }}"
56+
"github_token=${{ secrets.REGISTRY_TOKEN }}"
57+
5758
5859
deploy:
59-
needs: build-musl
60+
name: Deploy
6061
runs-on: ubuntu-latest
62+
needs: build-musl
63+
if: github.actor == github.event.repository.owner.login
64+
6165
steps:
62-
- name: Set secret as environment variable
63-
env:
64-
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
65-
run: echo "DISCORD_TOKEN=$DISCORD_TOKEN" >> $GITHUB_ENV
66+
- name: Set the Kubernetes context
67+
uses: azure/k8s-set-context@v2
68+
with:
69+
method: service-account
70+
k8s-url: ${{ secrets.SERVER_URL }}
71+
k8s-secret: ${{ secrets.KUBERNETES_SECRET }}
72+
73+
- name: Checkout source code
74+
uses: actions/checkout@v3
75+
76+
- name: Inject secret into manifest
77+
run: awk -i inplace -v secret="${{ secrets.DISCORD_TOKEN }}" '{gsub("DISCORD_TOKEN_SECRET", secret)}1' kubernetes/deployment.yaml
6678

67-
- name: Substitute secret in deployment YAML
68-
run: |
69-
envsubst < deployment.yaml > deployment_with_secret.yaml
7079

71-
- name: Deploy to Kubernetes
72-
run: kubectl apply -f deployment_with_secret.yaml
80+
- name: Deploy to the Kubernetes cluster
81+
uses: azure/k8s-deploy@v1
82+
with:
83+
action: deploy
84+
strategy: basic
85+
namespace: interspecies-reviewer
86+
manifests: |
87+
kubernetes/deployment.yaml
88+
images: |
89+
ghcr.io/guilamb/interspecies-reviewer:latest
90+
imagepullsecrets: |
91+
github-container-registry

0 commit comments

Comments
 (0)