-
Notifications
You must be signed in to change notification settings - Fork 423
56 lines (52 loc) · 1.99 KB
/
build-CI-container.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
52
53
54
55
56
name: build-CI-container
env:
REGISTRY: ghcr.io
# NOTE: IMAGE_NAME must be lowercase
IMAGE_NAME: chapel-github-ci
# NOTE: if this filename changes, also update in the on.paths section below
DOCKERFILE: util/packaging/docker/github-ci/Dockerfile
on:
push:
branches: [ main ]
# This limits the action so it only builds when this file changes
paths:
# unfortunately we can't use ${{env.DOCKERFILE}} here
# see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
- util/packaging/docker/github-ci/Dockerfile
# also trigger on changes to this workflow file itself
- .github/workflows/build-CI-container.yml
pull_request:
paths:
# same as for pushes above
- util/packaging/docker/github-ci/Dockerfile
- .github/workflows/build-CI-container.yml
# Adds a "manual run" option in the GH UI
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Image
uses: docker/[email protected]
with:
file: ${{ env.DOCKERFILE }}
# example: ghcr.io/chapel-lang/chapel-github-ci:latest
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
- name: Push Docker Image if on main
if: github.repository_owner == 'chapel-lang' && ((github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'push'))
uses: docker/[email protected]
with:
file: ${{ env.DOCKERFILE }}
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest