-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (69 loc) · 2.79 KB
/
docker-builds-symfony-app-runtime.yaml
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Docker builds (symfony-app-runtime)
on:
push:
branches:
- main
paths:
- .github/workflows/docker-builds-symfony-app-runtime.yaml
- docker/symfony-app-runtime/**
jobs:
symfony-app-runtime_build:
strategy:
matrix:
php-version: [ '8.0', '8.1' ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.ACCESS_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: ./docker/symfony-app-runtime
file: ./docker/symfony-app-runtime/${{ matrix.php-version }}-apache/Dockerfile
push: true
tags: |
mepagency/symfony-app-runtime:${{ matrix.php-version }}-apache
ghcr.io/${{ github.repository_owner }}/symfony-app-runtime:${{ matrix.php-version }}-apache
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/symfony-app-runtime:${{ matrix.php-version }}-apache
cache-to: type=inline
symfony-app-runtime_cleanup:
needs: [symfony-app-runtime_build]
runs-on: ubuntu-latest
steps:
# The following step needs an access token with permission to delete packages
- name: Untagged versions cleanup
uses: actions/github-script@v3
timeout-minutes: 5
with:
github-token: ${{ secrets.ACCESS_TOKEN }}
script: |
const response = await github.request('GET /${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions',
{ per_page: ${{ env.PER_PAGE }}
});
for (version of response.data) {
if (version.metadata.container.tags.length == 0) {
console.log('Deleting untagged version: ' + version.id);
const deleteResponse = await github.request('DELETE /${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions/' + version.id, { });
console.log('Status: ' + deleteResponse.status);
} else {
console.log('Skipping tagged version: ' + version.metadata.container.tags[0] + ' (' + version.id + ')');
}
}
env:
OWNER: orgs/${{ github.repository_owner }} # "user" or "orgs/<org name>"
PACKAGE_NAME: symfony-app-runtime
PER_PAGE: 100