Skip to content

Commit

Permalink
create gcp-publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor-Ultra authored Jun 26, 2023
1 parent f03897c commit 8c3a2c1
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/gcp-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: 'Uniq Discord Bot Publish'
on:
release:
types: [created]
jobs:
deploy-image:
strategy:
matrix:
include:
- environment: staging
name: 'STAGING'
wif: 'STG_WIF'
gcp: 'STG_GCP_PROJECT'
- environment: production
name: 'PRODUCTION'
wif: 'PROD_WIF'
gcp: 'PROD_GCP_PROJECT'

permissions:
contents: 'read'
id-token: 'write'

name: 'Build Discord Bot Docker Image'
runs-on: ubuntu-latest
steps:
- name: Set Release Version Variable (Tagged from CLI)
if: ${{ github.event.inputs.version == '' }}
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set Release Version Variable (Workflow GUI)
if: ${{ github.event.inputs.version != 'default-value' && github.event.inputs.version != '' }}
run: |
echo "RELEASE_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: 'Clone'
uses: actions/checkout@v2
with:
repository: 'ultraio/ultra-discord-uniq-roles-bot'
token: '${{ secrets.BLOCKCHAIN_CI_SECRET }}'
path: '.'
submodules: 'recursive'
ref: '${{ env.RELEASE_VERSION }}'
fetch-depth: 0

- name: 'Setup NodeJS 17+'
uses: actions/setup-node@v3
with:
node-version: 17

- id: 'auth'
name: '[${{ matrix.name }}] Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
token_format: 'access_token'
workload_identity_provider: '${{ secrets[matrix.wif] }}'
service_account: 'wif-gcr@${{ secrets[matrix.gcp] }}.iam.gserviceaccount.com'

- name: '[${{ matrix.name }}] Login to GCR'
uses: docker/login-action@v2
with:
registry: eu.gcr.io
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}

- name: 'Build Image'
env:
DOCKER_BUILDKIT: 1
run: |
docker build -t eu.gcr.io/${{ secrets[matrix.gcp] }}/ultra-uniq-discord-bot:${{ env.RELEASE_VERSION }} . --no-cache
- name: '[${{ matrix.name}}] Push Docker Image'
run: |
docker push eu.gcr.io/${{ secrets[matrix.gcp] }}/ultra-uniq-discord-bot:${{ env.RELEASE_VERSION }}

0 comments on commit 8c3a2c1

Please sign in to comment.