Improve text parsing on name registration (#44) #105
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: workflow | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
check-server: | |
name: check server | |
runs-on: ubuntu-latest | |
env: | |
PACKAGE_BASE_PATH: "${{ github.workspace }}/pkg" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: ./pkg/go.mod | |
cache-dependency-path: ./pkg/go.sum | |
cache: true | |
- name: Test code | |
run: make ci-test | |
- name: Upload test log | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: test-log | |
path: /tmp/gotest.log | |
if-no-files-found: error | |
check-front: | |
name: check front | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: front | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- run: npm ci | |
- run: npm run build | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: front-dist-${{ github.sha }} | |
path: ./front/dist | |
if-no-files-found: error | |
retention-days: 1 | |
if: github.ref == 'refs/heads/main' | |
release-server: | |
name: release server | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
permissions: | |
pull-requests: write | |
needs: | |
- check-server | |
- check-front | |
env: | |
TF_VERSION: "1.4.6" | |
defaults: | |
run: | |
working-directory: deploy | |
steps: | |
- uses: actions/checkout@v3 | |
# Go | |
- uses: actions/setup-go@v3 | |
with: | |
go-version-file: ./pkg/go.mod | |
cache-dependency-path: ./pkg/go.sum | |
cache: true | |
- run: make build before-deploy | |
working-directory: . | |
# GCP | |
- id: "auth" | |
uses: "google-github-actions/auth@v0" | |
with: | |
credentials_json: "${{ secrets.GCP_CREDENTIALS }}" | |
- uses: "google-github-actions/setup-gcloud@v0" | |
with: | |
project_id: haraiai | |
export_default_credentials: true | |
- run: "gcloud info" | |
# Terraform | |
- uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_version: ${{ env.TF_VERSION }} | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
- id: init | |
run: terraform init | |
- id: validate | |
run: terraform validate -no-color | |
- id: plan | |
if: github.event_name == 'pull_request' | |
run: terraform plan -no-color -input=false | |
continue-on-error: true | |
- uses: actions/github-script@v6 | |
if: github.event_name == 'pull_request' | |
env: | |
PLAN: "${{ steps.plan.outputs.stdout }}" | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const output = `#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\` | |
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\` | |
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\` | |
<details><summary>Show Plan</summary> | |
\`\`\`terraform\n | |
${process.env.PLAN} | |
\`\`\` | |
</details> | |
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
- run: exit 1 | |
if: steps.plan.outcome == 'failure' | |
- run: terraform apply -auto-approve -input=false | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
release-front: | |
name: release front | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
if: github.ref == 'refs/heads/main' | |
needs: | |
- check-server | |
- check-front | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: front-dist-${{ github.sha }} | |
path: ./dist | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@1 | |
with: | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
projectName: haraiai | |
directory: ./dist | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} |