Skip to content

Merge branch 'develop' #18

Merge branch 'develop'

Merge branch 'develop' #18

Workflow file for this run

name: RTMIS Release CI
on:
release:
types: [published]
jobs:
build_and_deploy_jobs:
name: RTMIS Build and Deploy Jobs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GKE auth plugin
uses: ./.github/actions/install-google-cloud-sdk
- name: Set short git commit SHA
id: vars
run: |
shortSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$shortSha" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create credentials folder
run: mkdir /home/runner/work/rtmis/credentials
shell: bash
- name: Write gcp deployment secret to file
run: echo "${{ secrets.GCLOUD_SERVICE_ACCOUNT }}" | base64 --decode > /home/runner/work/rtmis/credentials/gcp.json
shell: bash
- name: Write gcp deployment secret to file
run: echo "${{ secrets.RTMIS_SERVICE_ACCOUNT }}" | base64 --decode > /home/runner/work/rtmis/credentials/rtmis-service-account.json
shell: bash
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v41
- name: List all changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in "$ALL_CHANGED_FILES"; do
echo "$file was changed"
done
- name: Detect event type
run: |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
echo "PULL_REQUEST_EVENT=true" >> $GITHUB_ENV
else
echo "PULL_REQUEST_EVENT=false" >> $GITHUB_ENV
fi
- name: Build and test
env:
CI_COMMIT: ${{ env.COMMIT_SHORT_SHA }}
CI_BRANCH: ""
CI_TAG: ${{ github.ref_name }}
CI_PULL_REQUEST: ${{ env.PULL_REQUEST_EVENT }}
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
COMPOSE_INTERACTIVE_NO_CLI: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_RTMIS_TOKEN }}
SERVICE_ACCOUNT: "/home/runner/work/rtmis/credentials"
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }}
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: |
./ci/build.sh
- name: Deploy
env:
CI_COMMIT: ${{ env.COMMIT_SHORT_SHA }}
CI_BRANCH: ""
CI_TAG: ${{ github.ref_name }}
CI_PULL_REQUEST: ${{ env.PULL_REQUEST_EVENT }}
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
COMPOSE_INTERACTIVE_NO_CLI: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_RTMIS_TOKEN }}
SERVICE_ACCOUNT: "/home/runner/work/rtmis/credentials"
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: |
./ci/deploy.sh
mobile-app-release:
name: Mobile App Build
needs: build_and_deploy_jobs
runs-on: ubuntu-latest
steps:
- name: πŸ—„οΈ Checkout repository
uses: actions/checkout@v3
- name: 🧰 Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: πŸ— Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
run: |
echo "SENTRY_ENV='production'" >> $GITHUB_ENV
env:
SENTRY_ENV: ${{ env.SENTRY_ENV }}
SENTRY_DSN: ${{ secrets.SENTRY_MOBILE_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_MOBILE_AUTH_TOKEN }}
- name: πŸ“¦ Install dependencies
run: |
cd ./app/
cp ./src/build.staging.js ./src/build.js
npm install
- name: πŸš€ Release to Expo Dev
id: eas_release
working-directory: ./app
run: |
npm run eas:release > output.txt
cat output.txt
echo "APK_URL=$(tail -n 1 output.txt)" >> $GITHUB_ENV
- name: Set short git commit SHA
id: vars
run: |
shortSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$shortSha" >> $GITHUB_ENV
- name: Get App Version
id: get_version
run: |
cd app
apk_version=$(grep '"version":' package.json | sed -E 's/.*"version": *"([^"]+)".*/\1/')
echo "APK_VERSION=$apk_version" >> $GITHUB_ENV
- name: Send custom JSON data to Slack workflow
id: slack
uses: slackapi/[email protected]
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":iphone: [STAGING] New APK build just released - ${{ env.APK_VERSION }}",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*URL:*\n<${{ env.APK_URL }}>"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Commit ID:*\n<${{ github.event.pull_request.html_url || github.event.head_commit.url }}|${{ env.COMMIT_SHORT_SHA }}>"
},
{
"type": "mrkdwn",
"text": "*Created by:*\n${{ github.actor }}"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: 🌟 Send APK
env:
APK_VERSION: ${{ env.APK_VERSION }}
SECRET: ${{ secrets.APK_UPLOAD_SECRET }}
SENTRY_ENV: ${{ env.SENTRY_ENV }}
SENTRY_DSN: ${{ secrets.SENTRY_MOBILE_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_MOBILE_AUTH_TOKEN }}
run: |
curl -X 'POST' \
'https://rtmis.akvo.org/api/v1/device/apk/upload' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"apk_url": "'"$APK_URL"'",
"apk_version": "'"$APK_VERSION"'",
"secret": "'"$SECRET"'"
}'