[v6.0.30] #222
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: Full Workflow | |
env: | |
ARM_CLIENT_ID: ${{ secrets.TF_ARM_CLIENT_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.TF_ARM_CLIENT_SECRET }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.TF_ARM_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ secrets.TF_ARM_TENANT_ID }} | |
PRIVATE_KEY: ${{ secrets.VMPRIV }} | |
BOT_TOKEN: ${{secrets.NODE_DISC_API_KEY}} | |
OPENAI_API_KEY: ${{secrets.NODE_OPENAI_API_KEY}} | |
botDiscId: ${{secrets.NODE_DISC_BOT_ID}} | |
channelId: ${{secrets.NODE_DISC_CHANNEL_ID}} | |
guildId: ${{secrets.NODE_DISC_GUILD_ID}} | |
SPEECH_KEY: ${{secrets.SPEECH_KEY}} | |
commitMessage: ${{ github.event.head_commit.message }} | |
on: | |
push: | |
branches: ["main"] | |
# if change in file discordChatGPTVoice.js | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
buildImage: | |
runs-on: ubuntu-latest | |
steps: | |
#checkout from tag v1.1 | |
- name: Extract value from last commit message | |
id: extract | |
run: echo "::set-output name=value::$(echo ${{ github.event.head_commit.message }} | grep -oP '\[(.*?)\]' | tr -d '[]')" | |
- name: Use extracted value in another task | |
run: echo "Extracted value ${{ steps.extract.outputs.value }}" | |
- uses: actions/checkout@v2 | |
- name: Generate package.json | |
run: | | |
if [ -z "${{ steps.extract.outputs.value }}" ]; then | |
echo "No tag found in commit message" | |
exit 1 | |
fi | |
TAG=${{ steps.extract.outputs.value }} | |
sed -i s@TAG@$TAG@g package.json | |
sed -i s/VERSION_TO_BE_REPLACED/${{ steps.extract.outputs.value }}/g discordChatGPTVoiceBot.js | |
cat package.json | |
cat discordChatGPTVoiceBot.js | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Push to GitHub Container Registry | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/discbot:latest | |
env: | |
BOT_TOKEN: ${{secrets.NODE_DISC_API_KEY}} | |
startDocker: | |
needs: [buildImage] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- run: echo "$PRIVATE_KEY" > infra_app/ansible/VMPriv.pem | |
- run: chmod 600 infra_app/ansible/VMPriv.pem | |
- run: sed -i s/PRIVATE_IP/$(dig +short @ns1-34.azure-dns.com. discbotgpt.discbotgpt.com)/ infra_app/ansible/inventory | |
- name: Ansible Playbook | |
run: ansible-playbook -i infra_app/ansible/inventory infra_app/ansible/main.yaml --extra-vars "SPEECH_KEY=$SPEECH_KEY BOT_TOKEN=$BOT_TOKEN OPENAI_API_KEY=$OPENAI_API_KEY botDiscId=$botDiscId channelId=$channelId guildId=$guildId" | |
- name: Upload Ansible Artifact | |
uses: actions/upload-artifact@master | |
with: | |
name: ansible.out | |
path: infra_app/ansible/ansible.out | |
# destroy: # run after apply | |
# #run only if any job of the workflow fails | |
# if: ${{ github.event.inputs.name == 'DestroyAll' }} | |
# | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v2 | |
# - uses: hashicorp/setup-terraform@v2 | |
# - name: Terraform Init | |
# run: terraform -chdir=infra_app init | |
# #Destroy only VM, NIC, and Public IP | |
# - name: Terraform Destroy | |
# run: terraform -chdir=infra_app destroy |