Daily Pre-release #9
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: Daily Pre-release | |
on: | |
schedule: | |
- cron: '0 0 * * 1-5' # Runs Mon-Fri at midnight UTC | |
workflow_dispatch: # Allows manual trigger if needed | |
jobs: | |
create-pre-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main branch | |
uses: actions/checkout@v4 | |
with: | |
ref: main # Ensure we are working with the main branch | |
- name: Get latest commit hash | |
id: get_latest_commit | |
run: echo "COMMIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: Get current date | |
run: | | |
echo "CURRENT_DATE=$(date +%Y.%m.%d)" >> $GITHUB_ENV | |
echo "tag_name: $(date +%Y.%m.%d)" | |
- name: Create Pre-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
curl -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${{ github.repository }}/releases \ | |
-d '{ | |
"tag_name": "${{ env.CURRENT_DATE }}", | |
"target_commitish": "main", | |
"name": "${{ env.CURRENT_DATE }}", | |
"body": "Daily pre-release for ${{ env.CURRENT_DATE }}.", | |
"prerelease": true, | |
"draft": false, | |
"generate_release_notes": true | |
}' | |
# We cannot rely on the release_retag.yaml workflow because of the | |
# auth scope of the default github token. It's a good security practice | |
# to prevent a github action being triggered by another. | |
# So we will deliberately push to dockerhub below | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: mozilla/blurts-server | |
tags: type=sha,format=short,prefix= | |
- name: Tag Docker image with release tag | |
run: docker tag ${{ steps.meta.outputs.tags }} mozilla/blurts-server:${{ env.CURRENT_DATE }} | |
- name: Push Docker image with release tag | |
run: docker push mozilla/blurts-server:${{ env.CURRENT_DATE }} |