blob: a2f4be2d9f78e81b1b2237694157af9c4879b1da [file] [log] [blame]
Mohammed Naser1de55192023-04-28 17:13:35 -04001name: image
2
3on:
4 pull_request:
Mohammed Naser05d2af52024-01-01 21:11:26 -05005 paths-ignore:
Mohammed Naser93d643d2024-01-02 13:58:24 -05006 - images/**
Mohammed Naser05d2af52024-01-01 21:11:26 -05007 - go.mod
8 - go.sum
Mohammed Naser1de55192023-04-28 17:13:35 -04009 push:
10 branches:
11 - main
12 release:
13 types:
14 - published
15
Mohammed Naser55bbbf62023-04-28 22:24:55 +000016permissions:
17 packages: write
18 contents: read
19
Mohammed Naser1de55192023-04-28 17:13:35 -040020jobs:
21 build:
22 runs-on: ubuntu-latest
23 steps:
24 - name: Checkout project
renovate[bot]38929d42024-01-02 11:18:18 -050025 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
Mohammed Naser1de55192023-04-28 17:13:35 -040026
27 - name: Install Earthly
28 uses: earthly/actions-setup@v1
29 with:
30 github-token: ${{ secrets.GITHUB_TOKEN }}
31
Mohammed Naser55bbbf62023-04-28 22:24:55 +000032 - name: Login to GitHub Container Registry
renovate[bot]01f19a72024-04-03 11:30:53 -040033 uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
Mohammed Naser5c1338a2023-04-28 21:37:57 +000034 with:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000035 registry: ghcr.io
36 username: ${{ github.actor }}
37 password: ${{ secrets.GITHUB_TOKEN }}
Mohammed Naser5c1338a2023-04-28 21:37:57 +000038
Mohammed Naser1de55192023-04-28 17:13:35 -040039 - name: Build image
40 run: earthly +image --tag ${{ github.sha }}
41 env:
Mohammed Naser804d9122023-04-28 22:01:40 +000042 EARTHLY_CI: true
Mohammed Naser1de55192023-04-28 17:13:35 -040043 EARTHLY_PUSH: "${{ github.event_name == 'push' }}"
Mohammed Naserccc70cc2023-04-28 22:20:34 +000044 EARTHLY_REMOTE_CACHE: ghcr.io/vexxhost/atmosphere:cache
Mohammed Naser1de55192023-04-28 17:13:35 -040045
46 publish:
47 runs-on: ubuntu-latest
48 if: github.event_name == 'release'
49 needs:
50 - build
51 steps:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000052 - name: Login to GitHub Container Registry
renovate[bot]01f19a72024-04-03 11:30:53 -040053 uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
Mohammed Naser1de55192023-04-28 17:13:35 -040054 with:
Mohammed Naser55bbbf62023-04-28 22:24:55 +000055 registry: ghcr.io
56 username: ${{ github.actor }}
57 password: ${{ secrets.GITHUB_TOKEN }}
Mohammed Naser1de55192023-04-28 17:13:35 -040058
59 - name: Promote image
renovate[bot]38929d42024-01-02 11:18:18 -050060 uses: akhilerm/tag-push-action@85bf542f43f5f2060ef76262a67ee3607cb6db37 # v2.1.0
Mohammed Naser1de55192023-04-28 17:13:35 -040061 with:
Mohammed Naserccc70cc2023-04-28 22:20:34 +000062 src: ghcr.io/vexxhost/atmosphere:${{ github.sha }}
63 dst: ghcr.io/vexxhost/atmosphere:${{ github.event.release.tag_name }}