Release 5.0.1 #41
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: Release Dockerhub image | |
on: | |
pull_request: | |
branches: | |
- main | |
types: [closed] | |
jobs: | |
push_to_registry: | |
name: Tag Release ${{ github.head_ref }} and Push Docker image to Docker Hub | |
if: ${{ github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') }} | |
runs-on: ubuntu-latest | |
environment: enterprise | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Initialize mandatory git config | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email noreply@github.com | |
- id: get-release-vars | |
name: Configure Release Vars | |
run: | | |
echo "::set-output name=short_sha::$(git rev-parse --short=7 HEAD)" | |
echo "::set-output name=release_version::$(cat VERSION)" | |
- name: Create GH Release | |
uses: softprops/action-gh-release@v0.1.15 | |
with: | |
token: ${{ secrets.RELEASE_GITHUB_TOKEN }} | |
name: Release ${{ steps.get-release-vars.outputs.release_version }} - ${{ steps.get-release-vars.outputs.short_sha }} | |
tag_name: ${{ steps.get-release-vars.outputs.release_version }}-${{ steps.get-release-vars.outputs.short_sha }} | |
body: Autogenerated for ${{ steps.get-release-vars.outputs.release_version }}-${{ steps.get-release-vars.outputs.short_sha }}. Created for ${{ github.event.pull_request.html_url }} | |
# Configure Workload Identity Federation and generate an access token. | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: google-github-actions/auth@v1.0.0 | |
with: | |
token_format: 'access_token' | |
workload_identity_provider: ${{ secrets.CODECOV_GCP_WIDP }} | |
service_account: ${{ secrets.CODECOV_GCP_WIDSA }} | |
- name: Docker configuration | |
run: |- | |
echo ${{steps.auth.outputs.access_token}} | docker login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2.1.0 | |
with: | |
username: ${{ secrets.CODECOV_DEVOPS_DOCKER_USERNAME }} | |
password: ${{ secrets.CODECOV_DEVOPS_DOCKER_PASSWORD }} | |
# Push the Docker image from Google Artifact Registry to Dockerhub | |
- name: Publish | |
run: |- | |
COUNTER=0 | |
sleep 5 | |
while [ true ]; do | |
make pull-for-release && break || true | |
COUNTER=$(($COUNTER+1)) | |
if [ "$COUNTER" -gt 10 ]; then | |
echo "Timeout trying to download release image" | |
exit 1 | |
fi | |
echo Attempt $COUNTER | |
sleep 3 | |
done | |
make release |