Fix gcloud deploy manifest tarring #232
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: Build and release rc | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.24' | |
- name: Run tests | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: eu-north-1 | |
PROJECT_ID: entigo-infralib-agent | |
LOCATION: europe-north1 | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
ZONE: europe-north1-a | |
run: | | |
mkdir -p $(echo ~)/.config/gcloud | |
echo ${GOOGLE_CREDENTIALS} > $(echo ~)/.config/gcloud/application_default_credentials.json | |
gcloud auth activate-service-account --key-file=$(echo ~)/.config/gcloud/application_default_credentials.json | |
gcloud config set project $PROJECT_ID | |
gcloud auth list | |
gcloud config set account $(gcloud auth list --filter=status:ACTIVE --format="value(account)") | |
go test -timeout 25m -v ./... | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Get latest release | |
id: get_latest_release | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const latestStableRelease = await github.rest.repos.getLatestRelease({ owner: context.repo.owner, repo: context.repo.repo }); | |
const versionString = '' + latestStableRelease.data.tag_name; | |
const regex = /^v(\d+)\.(\d+)\.(\d+).*$/; | |
const match = versionString.match(regex); | |
const major = parseInt(match[1], 10); | |
const minor = parseInt(match[2], 10); | |
const patch = parseInt(match[3], 10) + 1; | |
const new_version = `v${major}.${minor}.${patch}` | |
core.setOutput('new_version', new_version); | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to Public ECR | |
uses: docker/login-action@v3 | |
with: | |
registry: public.ecr.aws | |
username: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
env: | |
AWS_REGION: us-east-1 | |
- name: Build and push image | |
run: | | |
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg VERSION=${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }} -t public.ecr.aws/entigolabs/entigo-infralib-agent:${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }} -t entigolabs/entigo-infralib-agent:${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }} . | |
- name: Authenticate with GitHub CLI | |
run: gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ github.event_name == 'push' }} | |
- name: Create Release | |
id: create_release | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git tag -a ${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }} -m "Release ${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }}" | |
git push origin ${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }} | |
RELEASE_URL=$(gh release create ${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }} \ | |
--title "Release ${{ steps.get_latest_release.outputs.new_version }}-rc${{ github.run_number }}" \ | |
--generate-notes \ | |
--draft=false \ | |
--latest=false \ | |
--prerelease=true) | |
echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_ENV | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: ${{ github.event_name == 'push' }} |