v1.0.0 of GitHub Action #11
Workflow file for this run
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
name: "Deploy: Cleaner Job" | |
on: | |
## REMOVE ME | |
pull_request: | |
types: [synchronize] | |
workflow_dispatch: {} | |
jobs: | |
publish: | |
name: 'Publish - ${{ matrix.project }}' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
project: [development, previews] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v1 | |
- name: '☁️ Project Id: ${{ matrix.project }}' | |
uses: actions/github-script@v7 | |
id: gcp-project-id | |
env: | |
GCP_PROJECT: ${{ matrix.project }} | |
GCP_PREVIEWS_PROJECT_ID: ${{ vars.GCP_PREVIEWS_PROJECT_ID }} | |
GCP_DEVELOPMENT_PROJECT_ID: ${{ vars.GCP_PREPRD_PROJECT_ID }} | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
if (process.env.GCP_PROJECT === 'development') { | |
return process.env.GCP_DEVELOPMENT_PROJECT_ID; | |
} else { | |
return process.env.GCP_PREVIEWS_PROJECT_ID; | |
} | |
- name: '☁️ Project Service Account: ${{ matrix.project }}' | |
uses: actions/github-script@v7 | |
id: gcp-sa-key | |
env: | |
GCP_PROJECT: ${{ matrix.project }} | |
GCP_PREVIEWS_KEY: '${{ secrets.GCP_SA_KEY }}' | |
GCP_DEVELOPMENT_KEY: '${{ secrets.GCP_PREVIEWS_SERVICE_ACCOUNT_KEY }}' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
if (process.env.GCP_PROJECT === 'development') { | |
return process.env.GCP_DEVELOPMENT_KEY; | |
} else { | |
return process.env.GCP_PREVIEWS_KEY; | |
} | |
- name: '☁️ Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: ${{ steps.gcp-project-id.outputs.result }} | |
credentials_json: ${{ steps.gcp-sa-key.outputs.result }} | |
- name: '☁️ Setup Cloud SDK' | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ steps.gcp-project-id.outputs.result }} | |
- name: '🐳 Authorize Docker push: ${{ matrix.project }}' | |
shell: bash | |
run: gcloud auth configure-docker us-docker.pkg.dev --quiet | |
- name: '🐳 Build and Push Container: ${{ matrix.project }}' | |
uses: actions/github-script@v7 | |
env: | |
GCP_PROJECT_ID: '${{ steps.gcp-project-id.outputs.result }}' | |
GCP_ARTIFACT_REPOSITORY: 'operations' | |
NAME: 'job-previews-cleaner' | |
DOCKER_TAGS: latest | |
DOCKER_DIRECTORY: './packages/cleaner' | |
DOCKER_FILE_NAME: 'Dockerfile' | |
GITHUB_SHA: '${{ github.sha }}' | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
const script = require('./scripts/docker.js'); | |
const { env } = process; | |
await script({ github, context, core, exec, env }); |