-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (43 loc) · 1.54 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Main
on:
push:
branches: ["main"]
# Ensure only one instance of the workflow is running at a time.
# This helps with race conditions when upserting releases.
concurrency:
group: "main"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write # Write is required to create/update releases AND to write tags
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate version based on date
run: echo "RELEASE_VERSION=$(date '+%Y-%m-%d_%H_%M')" >> $GITHUB_ENV
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:staging
build-args: |
APP_VERSION=${{ env.RELEASE_VERSION }}
- name: Upsert pending release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const createPrerelease = require('${{ github.workspace }}/.github/workflows/scripts/create-prerelease.js');
await createPrerelease({github, context, core}, "${{ env.RELEASE_VERSION }}");