Update state file after deployment #1
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 AO Processes | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: false | |
permissions: | |
contents: write | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install dependencies | |
run: npm ci | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.AO_DEPLOY_GCP_PROJECT_ID }} | |
service_account_key: ${{ secrets.AO_DEPLOY_GCP_SA_KEY }} | |
- name: Get wallet from Google KMS | |
run: | | |
echo '${{ secrets.AO_DEPLOY_GCP_SA_KEY }}' > gcp-sa-key.json | |
gcloud auth activate-service-account --key-file=gcp-sa-key.json | |
gcloud kms decrypt \ | |
--location=europe \ | |
--keyring=ao-deploy \ | |
--key=ao-deploy \ | |
--project=ao-deploy \ | |
--ciphertext-file=keys/arweave-key.enc \ | |
--plaintext-file=wallet.json | |
echo "WALLET_JSON=$(cat wallet.json)" >> $GITHUB_ENV | |
rm gcp-sa-key.json # Remove the key file after use | |
- name: Determine config file | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
echo "CONFIG_FILE=processes.prod.yaml" >> $GITHUB_ENV | |
elif [[ "${{ github.ref }}" == "refs/heads/staging" ]]; then | |
echo "CONFIG_FILE=processes.staging.yaml" >> $GITHUB_ENV | |
else | |
echo "CONFIG_FILE=processes.dev.yaml" >> $GITHUB_ENV | |
fi | |
- name: Run aoform | |
run: npx aoform apply -f ${{ env.CONFIG_FILE }} | |
- name: Commit state file | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add state-${{ env.CONFIG_FILE }} | |
git commit -m "Update state file after deployment" || echo "No changes to commit" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |