-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
56 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,20 +18,15 @@ jobs: | |
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set outputs | ||
id: vars | ||
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install Dependencies and Compile Assets | ||
- name: Install Docker Compose | ||
run: | | ||
npm install | ||
npm run prod | ||
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | ||
sudo chmod +x /usr/local/bin/docker-compose | ||
docker-compose --version | ||
- name: Make Cache Directory | ||
run: mkdir bootstrap/cache | ||
|
||
- name: Build Docker Image | ||
run: docker-compose build --no-cache | ||
|
@@ -45,55 +40,41 @@ jobs: | |
- name: Push to Docker Hub (Master) | ||
if: contains(github.ref, 'master') | ||
run: | | ||
docker tag vatusa/www vatusa/www:${{ steps.vars.outputs.sha_short }} | ||
docker push vatusa/www:${{ steps.vars.outputs.sha_short }} | ||
docker tag vatusa/www vatusa/www:${{ github.sha }} | ||
docker push vatusa/www:${{ github.sha }} | ||
- name: Push to Docker Hub (Dev) | ||
if: contains(github.ref, 'dev') | ||
run: | | ||
docker tag vatusa/www vatusa/www:dev | ||
docker push vatusa/www:dev | ||
- name: Install kubectl | ||
uses: azure/setup-kubectl@v3 | ||
with: | ||
version: 'v1.21.2' | ||
docker tag vatusa/www vatusa/www:dev-${{ github.sha }} | ||
docker push vatusa/www:dev-${{ github.sha }} | ||
- name: Create kubeconfig | ||
run: | | ||
mkdir ~/.kube | ||
cat << EOF > ~/.kube/config | ||
apiVersion: v1 | ||
clusters: | ||
- cluster: | ||
certificate-authority-data: ${{ secrets.KUBECONFIG_CLUSTER_CERT_AUTH_DATA }} | ||
server: ${{ secrets.KUBECONFIG_CLUSTER_SERVER }} | ||
name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | ||
contexts: | ||
- context: | ||
cluster: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | ||
user: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}-admin | ||
name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | ||
current-context: ${{ secrets.KUBECONFIG_CLUSTER_NAME }} | ||
kind: Config | ||
preferences: {} | ||
users: | ||
- name: ${{ secrets.KUBECONFIG_CLUSTER_NAME }}-admin | ||
user: | ||
token: ${{ secrets.KUBECONFIG_CLUSTER_TOKEN }} | ||
EOF | ||
- name: Deploy to Kubernetes Cluster - Update Deployment | ||
if: contains(github.ref, 'master') | ||
deploy: | ||
name: Deploy to ArgoCD | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'VATUSA/gitops' | ||
path: gitops | ||
token: ${{ secrets.G_TOKEN }} | ||
- name: Setup Kustomize | ||
uses: imranismail/setup-kustomize@v2 | ||
- name: Update manifests | ||
run: | | ||
kubectl set image deployment/www *=vatusa/www:${{ steps.vars.outputs.sha_short }} -n web | ||
- name: Deploy to Kubernetes Cluster - Update Cron Job | ||
if: contains(github.ref, 'master') | ||
cd $GITHUB_WORKSPACE/gitops/current | ||
kustomize edit set image vatusa/www=vatusa/www:${{ github.sha }} | ||
- name: Commit and push changes | ||
run: | | ||
kubectl set image cronjob/www-cron *=vatusa/www:${{ steps.vars.outputs.sha_short }} -n web | ||
- name: Deploy to Kubernetes Cluster - Update Queue Worker | ||
if: contains(github.ref, 'master') | ||
cd $GITHUB_WORKSPACE/gitops | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "VATUSA6" | ||
git add . | ||
git commit -m "Update WWW image tag to ${{ github.sha }}" | ||
- name: Push to gitops repo | ||
run: | | ||
kubectl set image deployment/www-queue *=vatusa/www:${{ steps.vars.outputs.sha_short }} -n web | ||
cd $GITHUB_WORKSPACE/gitops | ||
git push origin main | ||