Sidecar build for linux #4
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: Sidecar build for linux | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest # Run this job on a macOS environment | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Rust | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
- name: Build | |
run: | | |
cargo build --release | |
# Install gcp skcd | |
- name: Setup GCP SDK | |
uses: 'google-github-actions/setup-gcloud@v0' | |
with: | |
project_id: '${{ env.GCP_PROJECT_ID }}' | |
service_account_key: '${{ secrets.GCP_SA_KEY }}' | |
# Setup auth for gcp | |
- name: GPC Auth | |
uses: 'google-github-actions/auth@v0' | |
with: | |
credentials_json: '${{ secrets.GCP_GAE_SA_KEY }}' | |
# Now run the .sh script which does the building and packaging | |
- name: Build and package | |
run: | | |
./package.sh | |
- name: Upload to GCP bucket generated zip file | |
env: | |
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
GCP_BUCKET_NAME: ${{ secrets.GCP_BUCKET_NAME }} | |
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | |
run: | | |
# Decode the GCP_SA_KEY secret and write the contents to a temporary file | |
echo "$GCP_SA_KEY" | base64 --decode > gcp_sa_key.json | |
# Authenticate to gcloud with the service account key | |
gcloud auth activate-service-account --key-file=gcp_sa_key.json | |
# Set your GCP project | |
gcloud config set project $GCP_PROJECT_ID | |
# Copy the built binary to the GCP bucket | |
gsutil cp sidecar.zip gs://sidecar-bin/linux/sidecar.zip | |
# Remove the service account key file | |
rm gcp_sa_key.json |