-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
f03897c
commit 8c3a2c1
Showing
1 changed file
with
74 additions
and
0 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 |
---|---|---|
@@ -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 }} |